For the convenience of work, not regularly updated.
-----------------------------------------
1. Verify the phone number
function Formatphone (str) {var re =/^1[34578][0-9]{9}$/g;return re.test (str);};
2. remove all spaces in the string, not just the front and back spaces:
Text = Text.replace (/\s/ig, ");
3. Check the URL
Check URL (very comprehensive) function Isurl (str_url) {var Strregex = ' ^ (HTTPS|HTTP|FTP|RTSP|MMS)?:/ /) ' + '? ([0-9a-z_!~*\ ' (). &=+$%-]+:)? [0-9a-z_!~*\ ' (). &=+$%-] [email protected])? ' FTP [email protected] + ' ([0-9]{1,3}.) {3} [0-9] {1,3} '//IP URL-199.194.52.184 + ' | '//Allow IP and domain (domain name) + ' ([0-9a-z_!~*\ ' ()-]+.) * '//Domain name-www. + ' ([0-9a-z][0-9a-z-]{0,61})? [0-9a-z]. ' Level two domain name + ' [a-z]{2,6}] '//First levels domain-. com or. Museum + ' (: [0-9]{1,4})? '//Port-: + ' ((/?) | '//A slash ' t r equired If there is no file name + ' (/[0-9a-z_!~*\ ' ();?: @&=+$,%#-]+) +/?) $ '; var re=new RegExp (Strregex); Re.test () if (Re.test (Str_url)) {return (true);} else {return (false);}}
4. Whether it is an integer
/* is an integer */function Iszhengshu (number) {var r =/^\+?[ 1-9][0-9]*$/;return r.test (number);}
Various useful regular expressions