I ignore case
G Global Match
M multi-line matching
/*
Zip match
var pattern =/^[\w\-]+\. (Zip|gz|rar) $/; [a-za-z0-9_] can be replaced with \w
Plus ^ Qualifying first character match
var str = ' 2-13.rar '; File Name: letter _ number. zip,gz,rar,7z
document.write (Pattern.exec (str));
Compress Package name matching
var pattern =/^[\w\-]+\.zip|gz|rar/; [a-za-z0-9_] can be replaced with \w//plus ^ qualifier first character match
var str = ' 2-13.zip '; File Name: letter _ number. zip,gz,rar,7z
document.write (Pattern.test (str));
var pattern =/^ ([\w\.\-]+) @ ([\w\-]+) \. ([a-za-z]{2,4}) $/;
var str = ' [email protected] ';
document.write (Pattern.test (str));
*/
This article is from the "Walk to New York" blog, please be sure to keep this source http://bubucuo9195.blog.51cto.com/4040646/1561662
JavaScript regular expression matching zip code and mailbox