adsense


Thursday, 12 November 2015

ADVANCE VB SCRIPT BUILDING REGULAR EXPRESSIONS PAGE 205

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button




ADVANCE VB SCRIPT BUILDING REGULAR EXPRESSIONS





Building Regular Expressions 
Given below are a few examples that clearly explain how to build a Regular Expression. 



Regular Expression 	Description 

"^\s*.." and "..\s*$" 	Represents that there can be any number 
                        of leading and trailing space characters in a single line. 

"((\$\s?)|(#\s?))?" 	Represents an optional $ or # sign followed by an optional space. 

"((\d+(\.(\d\d)?)?))" 	Represents that at least one digit is present 
                        followed by an optional decimals and two digits after decimals. 
Example 
The below example checks whether or not the user entered an email id 
whose format should match such that there is an email id followed by '@' 
and then followed by domain name. 

<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
  strid = "welcome.user@tutorialspoint.co.us" 
  Set re = New RegExp 
  With re 
      .Pattern    = "^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$" 
      .IgnoreCase = False 
      .Global     = False 
  End With 
   
  ' Test method returns TRUE if a match is found 
  If re.Test( strid ) Then 
      Document.write(strid & " is a valid e-mail address") 
  Else 
      Document.write(strid & " is NOT a valid e-mail address") 
  End If 
   
  Set re = Nothing 
</script> 
</body> 
</html> 




No comments: