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}$/;//ID 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}$/; identity card consolidation: (^\d{15}$) | (^\d{17} ([0-9]| X) $)
The latest mobile phone number regular expression:
var tel = $ ("#telNo"). Val (); Get mobile number var Telreg =!! Tel.match (/^ (0|86|17951)? ( 13[0-9]|15[012356789]|17[678]|18[0-9]|14[57]) [0-9]{8}$/);//If the mobile number cannot be verified by the IF (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 information from the image link: (s| S) (r| R) (c| C) *= * (' | ')? (\w|\\|\/|\.) + (' | ' | *|>)? The IP address in the extracted information: (\d+) \. (\d+) \. (\d+) \. (\d+) Chinese mobile phone number in extracting information: (*0*13\D{9) The Chinese fixed phone number in extracting information: (\ (\d{3,4}\) |\d{3,4}-|\s)? \d{8} Extract the Chinese phone number (including mobile and landline) in the information:(\ (\d{ 3,4}\) |\d{3,4}-|\s)? \d{7,14} Extracting information from China Postcode: [1-9]{1} (\d+) {5} Extracting information from Chinese identity card number: \d{18}|\d{15} integer in Extract information: \d+ Extract floating-point numbers (that is, decimals) in information: (-?\d*) \.? \d+ extract any number in the information: (-?\d*) (\.\d+)? Extract the Chinese string in 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.
var pattern = new RegExp (' box ', ' I '); var str = ' box '; alert (Pattern.test (str)); Truevar pattern =/box/i;var str = ' Box '; alert (Pattern.test (str)); Truevar pattern =/box/i;var str = ' This is a Box '; Alert (Pattern.test (str)); True
JS Latest mobile phone number, ID card regular expression