/^d{3,4}-d{7,8} (-d{3,4})? The $/area code must be filled with a 3-4-digit number, followed by "-" to connect to the phone number
^d{3,4}-number with 7-8 digits
d{7,8} extension number is 3-4 digits, not required, but if filled with "-" and telephone number to connect
(-d{3,4})? cell phone number Regular expression
Verify the mobile phone number, ignore the front 0, support 130-139,150-159. Ignore the front 0 and judge it to be 11-bit.
The regular of the Cloeft:
/^0* (13|15) d{9}$/^0* matches any number of the initial 0.
Because the mobile phone number is 13 any number 9 bits, and 15 any number 9 bits, so can use (13|15) d{9} match.
The test code is as follows:
code is as follows |
copy code |
function Testreg (reg,str) { return reg.test (str); } var reg =/^0* (13|15) d{9}$/; var str = ' 13889294444 '; var str2 = ' 12889293333 '; var str3 = ' 23445567 '; document.write (Testreg (reg,str) + ' <br/> '); document.write (Testreg (REG,STR2) + ' <br/> '); document.write (Testreg (REG,STR3) + ' <br/> '); |