Sunday, 27 April 2014

QTP - UFT - How to use regular expressions?



How to use regular expression - code please to find a some sting in a large string
Regular expressions are very handy with Scripting and can be used in multiple ways. I would like to present once scenario on its usage.

Syntax
inputstring = "This Blog helps you with learn and test your skills on UFT"
Set o1 = new RegExp
o1.pattern = "learn"
o1.ignorecase = true
o1.global = true
Set r1 = o1.execute(inputstring)

For Each Match in r1
  Flag =1
  str = str & Match.firstindex & " - "
 Next
If Flag =1 Then
 msgbox "match found at locations " & str
End If

No comments:

Post a Comment