QTP regular expression

Total Post:88


 1901  View(s)
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. 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.

      Modified On Mar-30-2018 04:25:27 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.