Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the regular expressions of commonly used certificate numbers

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you what the regular expressions of commonly used document numbers are. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Regular expressions (Regular Expression, often abbreviated as regex, regexp, or RE in code) is a concept in computer science. Regular expressions use a single string to describe and match a series of strings that conform to a syntactic rule. In many text editors, regular expressions are often used to retrieve and replace text that matches a certain pattern. Many programming languages support string manipulation using regular expressions. In many text editors, regular expressions are often used to retrieve and replace text that matches a certain pattern.

Regular expressions are used in string processing, form verification and other occasions, practical and efficient. Some commonly used expressions are collected here for a rainy day.

/ * * verify whether it is in EMAIL format * / public static final String EMAIL = "('') | (\\ w+ ([- +.]\\ w+) * @ ([-.]\\ w+) *\.\\ w+ ([-.]\\ w+) *)" / * * verify phone number * / public static final String TELEPHONE = "('') | (\\ d {4} (- *)\\ d {8} |\ d {4} (- *)\\ d {7} |\ d {3} (- *)\\ d {8} |\\ d {3} (- *)\\ d {8}); / * * verify mobile phone number * / public static final String MOBILEPHONE =" 1 (3 | 5 | 8 | 7)\ d {9} " / / "[1] [3 | 5 | 8] +\\ d {9}"; / * * verify whether it is a phone or mobile phone number * / public static final String TELEMOBILE = "^ ((\\ d {3Power4}?-|\ (\ d {3Power4}\))?\ d {8pm 11} $) | (^ 0 {0pm 1} 13 [0-9] {9} $)" / * * is it all in Chinese * / public static final String CHINESECHAR = "^ [\ u4e00 -\ u9fa5] + $"; / * * check if there is a HTML tag in the string * / public static final String HTMLTAGHAS = "] * >. * |; / * * check whether URL is legal * / public static final String URL =" [a-zA-z] +: / / [^\\ s] * " / * * check whether IP is legal * / public static final String IPADRESS = "\\ d {1Magne3} +\\.\ d {1Magne3} +\.\ d {1Magne3} +\.\ d {1Magne3}; / * * check whether the QQ number is legal * / public static final String QQCODE =" [1-9] [0-9] {4pr 13} " / * * check whether the zip code is legal * / public static final String POSTCODE = "[1-9]\\ d {5} (?!\\ d)"; / * positive integer * / public static final String POSITIVE_INTEGER = "^ [0-9]\\ dstamp $" / * * positive floating point number * / public static final String POSITIVE_FLOAT = "^ [1-9]\\ dnumbers.\\ d * | 0.\\ d * [0-9]\\ d *"; / * * integer or decimal * / public static final String POSITIVE_DOUBLE = "^ [0-9] + (\. [0-9] +)? $" / * * on the day of the month 2012-1-1 of 2012, there is a scene in 2012. * / public static final String DATE_YMD = "^\\ d {4} (\\-|\ / |.)\\ d {1Magne2}\\ 1\ d {1Magne2} $" / * * when checking whether the ID card is legally verified, please verify that the length is 15 or 18 digits * / public static final String IDCARD = "\\ d {6} (19 | 20) * [0-99] {2} (0 [1-9] {1} | 10 | 11 | 12) (0 [1-9] {1}" + "| 1 [0-9] | 2 [0-9] | 30 | 31) (\\ w*)" / * * check whether the passport is legal * / public static final String PASSPORT1 = "/ ^ [a-zA-Z] {5pm 17} $/"; public static final String PASSPORT2 = "/ ^ [a-zA-Z0-9] {5pm 17} $/"; / * * Hong Kong and Macao pass verification * / public static final String HKMAKAO = "/ ^ [HMhm] {1} ([0-9] {10} | [0-9] {8}) $/" / * * Taiwan pass Verification * / public static final String TAIWAN1 = "/ ^ [0-9] {8} $/"; public static final String TAIWAN2 = "/ ^ [0-9] {10} $/"

/ / passport verification

JQuery.validator.addMethod ("isPassport", function (value, element, type) {if ($(type). Val () = ='2') {varre1 = / ^ [a-zA-Z] {5pm 17} $/; varre2 = / ^ [a-zA-Z0-9] {5pm 17} $/; returnthis.optional (element) | | (re2.test (value)) | | re1.test (value);} else {returntrue;}}, "passport format is incorrect")

/ / Hong Kong and Macao pass verification

JQuery.validator.addMethod ("isHKMacao", function (value, element, type) {if ($(type). Val () = ='3') {varre = / ^ [HMhm] {1} ([0-9] {10} | [0-9] {8}) $/; returnthis.optional (element) | | (re.test (value));} else {returntrue;}}, "Hong Kong and Macao pass format is incorrect")

/ / Taiwan pass verification

JQuery.validator.addMethod ("isTaiwan", function (value, element, type) {if ($(type). Val () = = "4") {varre1 = / ^ [0-9] {8} $/; varre2 = / ^ [0-9] {10} $/; returnthis.optional (element) | | (re1.test (value)) | | (re2.test (value))} else {returntrue;}}, "Taiwan pass is not in the correct format"). Thank you for reading! This is the end of this article on "what are the regular expressions of commonly used ID numbers?". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report