Monday, June 29, 2015

Regular Expression

.(dot)* ---- this will help you find any character.

Ex: Page("title:=.*")....

It will retrieve page with any title.



- Other way is by creating object, as we do in VBscripting(macro)

Source: http://uftquestions.blogspot.com/2014/04/qtp-uft-how-to-use-regular-expressions.html

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