Regular expressions (regular expression) are an object that describes the character pattern. Use regular expressions to perform powerful pattern matching and text retrieval and replacement functions.
ID Card Regular:
//identity card Regular expression (15-bit)isidcard1=/^[1-9]\d{7}((0\d) | (1[0-2]))(([0|1|2]\D) |3[0-1]) \d{3}$/;//identity card Regular expression (18-bit)isidcard2=/^[1-9]\d{5}[1-9]\d{3}((0\d) | (1[0-2]))(([0|1|2]\D) |3[0-1]) \d{4}$/the identity card is consolidated: (^\d{ the}$)| (^\d{ -}([0-9]| X) $)
The latest mobile phone number regular expression:
varTel = $ ("#telNo"). Val ();//Get Phone numbervarTelreg =!! Tel.match (/^ (0| the|17951)? ( -[0-9]| the[012356789]| -[678]| -[0-9]| -[ $])[0-9]{8}$/);//If the phone number does not pass verificationif(Telreg = =false){ }
Other
To extract information from a network link: (h| H) (r| R) (e| E) (f| F) *= * ('|")? (\w|\\|\/|\.) +('|"| *|>)?Message address in Extract information: \w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *Extract the image link in the information: (S| S) (r| R) (c| C) *= * ('|")? (\w|\\|\/|\.) +('|"| *|>)?Extract the IP address in the information: (\d+) \. (\d+) \. (\d+) \. (\d+) The Chinese mobile phone number in the extracted information: ( the)*0* -\d{9The Chinese fixed phone number in the extracted information: (\ (\d{3,4}\) |\d{3,4}-|\s)? \d{8the Chinese phone number in the extract information (including mobile and landline):(\ (\d{3,4}\) |\d{3,4}-|\s)? \d{7, -Extract the information in China postcode: [1-9]{1} (\d+) {5the Chinese identity card number in the extracted information: \d{ -}|\d{ theextract the Integer in the information: \d+extract floating-point numbers (that is, decimals) in information: (-?\d*) \.? \d+extract any number from the information: (-?\d*) (\.\d+)?extract the Chinese string from the message: [\u4e00-\u9fa5]*extract the Double-byte string in the message (Kanji): [^\x00-\xff]*
Use:
The test () method looks in the string for the presence of the specified regular expression and returns a Boolean value that returns true if it exists, otherwise false.
varPattern =NewREGEXP ('Box','I');varstr ='Box'; alert (Pattern.test (str));//truevarPattern =/box/i;varstr ='Box'; alert (Pattern.test (str));//truevarPattern =/box/i;varstr ='This is a box'; alert (Pattern.test (str));//true
2015 latest mobile phone number, ID, regular expression