Sunday, 5 November 2017

Vbscript: Instr() or Regular Expression

 sString = “Welcome User, You have 5 New Mails”
 sSubString = “Welcome .*, You have .* New Mails”‘Check if the string pattern matches – using 

RegExp object
Set objRE = New RegExp
objRE.Global = True
objRE.Pattern = sSubString
msgbox objRE.Execute(sString).Count ‘ — msgbox returns the value 1 as the RegExp object returns 1 match 

‘Check if the string pattern matches  – using InStr
msgbox InStr(1, sString, sSubString, 1)  ‘ — msgbox returns the value 0  as it is not able to find the match using InStr

No comments:

Post a Comment

Spring Boot : Exception Handler 14