Friday, March 1, 2013

VBS: Regular Expression

 VBS: Regular Expression



Example 1 :
set regex=new regexp
regex.pattern="((9|8)[0-9]{9})"

a=inputbox("enter data")
if regex.test(a) = true and len(a)=10 then
 msgbox "valid"
else
 msgbox "invalid"
end if


Example 2 :

set regex=new regexp
regex.pattern="www\..*\.(com|in|jp)$"
n=inputbox("validate any website address starting from --www")
if regex.test(n) then
 msgbox "valid"
else
 msgbox "invalid"
End if

No comments:

Post a Comment