Micro Focus QTP (UFT) Forums
Regular expression in descriptive programming - 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: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Regular expression in descriptive programming (/Thread-Regular-expression-in-descriptive-programming)



Regular expression in descriptive programming - testernc - 01-30-2014

I am trying to use regular expression in variable declaration with in a function.

Code:
Function FieldExistOrNot(label)
    Dim flag
    Dim objDescription
    Set objDescription = Description.Create()
    objDescription("ClassName").Value = "WebElement"
    objDescription("innertext").RegularExpression = True
    objDescription("html tag").value ="LABEL"
      objDescription("innertext").value = ".*" &label& ".*"
    MsgBox objDescription("innertext").value
    flag = Browser("Name:=Home Page for.*").page("Title:=Home Page for.*").Frame("title:=Content Check-In.*").WebTable("Text:=Content Check-In.*").WebElement(objDescription).exist

End Function
Above is my script. I have to define innertext value using input parameter label and regular expression.

When it is executed, i am getting the innertext value as ".*label.*"


RE: Regular expression in descriptive programming - anshika.agarwal - 12-08-2014

If you use .* at the start then the regular expression will exclude anything you have entered after it so QTP would not recognise the innertext properly. If possible then use .* always at the end like :
Code:
"value:=" &label& ".*"