Micro Focus QTP (UFT) Forums

Full Version: String Comparison using escape character
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
try without any escape character.
its working in my system i have QTP 11.
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