Micro Focus QTP (UFT) Forums
String Comparison using escape character - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: String Comparison using escape character (/Thread-String-Comparison-using-escape-character)



String Comparison using escape character - Charanpreet - 04-21-2011

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.


RE: String Comparison using escape character - Jay - 04-21-2011

try without any escape character.
its working in my system i have QTP 11.


RE: String Comparison using escape character - sreekanth chilam - 04-21-2011

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