QTP Normalize String - Convert a String into Regular Expression using VB Script

'This function will convert a Normal String into Regular expression that can be easily utilized with your QTP 'Script.Hence the name of the function provided as Normalize String.
'It is Reusable code can be utilized as it is.

Function NormalizeString(OrgStr)

    Dim TempStr

    TempStr = Replace(OrgStr, "\", "\\")

    TempStr = Replace(TempStr, "*", "\*")

    TempStr = Replace(TempStr, "+", "\+")

    TempStr = Replace(TempStr, ".", "\.")

    NormalizeString = Replace(TempStr, "?", "\?")

End function

msgbox NormalizeString ("a+b*c.d?e")



'If anyone have any question in this kindly post them, I would be happy to resolve them.

Comments