Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String Comparison using escape character
#1
Solved: 11 Years, 3 Months, 3 Weeks ago Question 
Want to check whether following string exists in the existing string or not:-

Code:
str1 = "(%,&,_,?,#,=,-) :"
str2 = "abcd(%,&,_,?,#,=,-) :xwyz"
comparestr = instr(str2 ,str1)

Am getting failure.

I have used escape character like as below as well
Code:
str1 = "\(\%,\&,_,\?,#,=,-\) :"

Still failure.
Any help will be appreciated.
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
try without any escape character.
its working in my system i have QTP 11.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

Try with the below example.
Here we go.

Code:
str1 = "abcd(%,&,_,?,#,=,-) :xwyz"
str2 = "(%,&,_,?,#,=,-) :"
If (Instr(1,str1,str2)>0) then
   Msgbox "Substring is present in given string"
Else
   Msgbox "Substring is not present in given string"
End if

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Not able to use wild character in string amit25007 2 2,602 03-09-2016, 10:36 AM
Last Post: amit25007
  String Pattern : Alternet Character Capital abhideshpande001 4 3,541 09-03-2015, 03:43 PM
Last Post: abhideshpande001
  VB Script:number of times a character appears in a string with position Jyobtech 1 12,060 08-07-2013, 01:03 PM
Last Post: anil2u
Smile Excel Comparison Sathiya 0 2,343 12-15-2011, 12:47 PM
Last Post: Sathiya
  How to have a variable that has a string comma string .. shareq1310 5 5,060 11-09-2011, 03:33 PM
Last Post: parminderdhiman84

Forum Jump:


Users browsing this thread: 1 Guest(s)