QTP REGULAR EXPRESSION

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
 1288  View(s)
Ratings:
Rate this:
Hi Expert,

I have problem with regular expression in QTP, can't understand why this pattern doesn't work:

Dim objRegExp
Set objRegExp = New RegExp
                objRegExp.Pattern = Replace(Replace(Replace("Millennium [AUT]", "\", "\\"), "(", "\("), ")", "\)")
                objRegExp.IgnoreCase = True
If objRegExp.Execute("Millennium [AUT]").Count < 1 Then
    Set objRegExp = Nothing
End If


Method Count return 0 value, could someone help, pls.
  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: QTP regular expression

    Hi Jacob!


    Your .Replace chain does not change the pattern "Millennium [AUT]" which searchs for "Millennium" follwed by " ", followd by one letter out of "A", "U", or "T". Your input "Millennium [AUT]" has a "[" where the pattern expects "A", "U", or "T".

    So please follow the general rule when asking for solutuions of regexp problems: Give at least one sample input and its expected outcome.

    Perhaps you meant:

    set r = New RegExp
    r.Pattern = "Millennium \[AUT\]"
    set mts = r.Execute("Millennium [AUT]")
    WScript.Echo mts.Count

    I hope it helpful for you.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!