In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what regular expressions are commonly used at the front end, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article. Let's learn about it!
Match URL
Const regexURL = / ((https? | ftp)?::\ /\ /)? (www\.)? [- a-zA-Z0-9 colors _%. _\ + ~ # =] {2256}\. [a _ murz] {2 a-zA-Z0 6}\ b ([- a-zA-Z0-9 colors _% _\ +. ~ #? & / / =] *) / gi / / this rule can match such a format of url//www.baidu.com// http://www.baidu.com//https://www.baidu.com//baidu.com//test.baidu.com / / gds.baidu.com// ftp://www.baidu.com//-split line-- / / maybe there are partners who don't need to match such a big block, as long as they match http and https. Just rewrite the above: const regexURL = / (https?:\ /\ /) (www\.)? [- a-zA-Z0-9 colors _%. _\ + ~ # =] {2256}\. [a _ murz] {2 a-zA-Z0 6}\ b ([- a-zA-Z0-9 colors% _\ +. ~ #? & / / =] *) / gi / / http://www.baidu.com//https://www.baidu.com
It is not very reliable to match the Chinese ID card.
/ / Why is it unreliable? Because const regexCHINAIDCARD = / ^ ((1 [1-5])) | (2 [1-3]) | (3 [1-7]) | (4 [1-6]) | (5 [1-4]) | (6 [1-5]) | 71 | (8 [12]) | 91)\ d {4} ((19\ d {2} (0 [13-9])) | 012]) (0 [1-9] | [12]\ d | 30)) | (19\ d {2} (0 [13578] | 1 [02]) 31) | (19\ d {2} 02 (0 [1-9] | 1\ d | 2 [0-8])) | (19 ([13579] [26] | [2468] [048]) 0229))\ d {3} (\ d | X | x)? $/ gi / / can match such a pile of ID cards, ID card numbers are all searched on the Internet, one search pile / / 230381198104143414//650201199007186135//460106197707275739//44200019860325932X//43052819880216450X//654223197502255401
Match numbers, integers, floating point ~ ~
/ / this product will only match positive integers const regexInteger = / ^\ dBandpool / definitely someone wants to ask, if it is an integer of bounded nature, let me change it, for example, 0-100const regexRangeInteger = / ^\ d$ | ^ [1-9]\ d$ | ^ 100 $/ gi / / what about matching decimals, const regexFloat = / ^\ d +\. D+$/gi// if you want to limit it, such as that, any integer and floating point number const regexRangeIntFloat = / ^ (\ d {0re2} (\.\ d +)?) $/ gi.
Match the mobile phone number
/ / excluding satellite phones, these are only common mobile phone ranges listed, taking into account the region and the long-distance prefix const regexMobileNumber = / ^ (0 | 86 | 17951)? (13 [0-9] | 15 [012356789] | 17 [012356789] | 18 [0-9]) [0-9] {8} $/ gi
Match mailbox
Const regexEmail = / ^ ([^ ()\ [\]\.;:\ s @ "] + (\. [^ ()\ [\]\. :\ s @ "] +) *) | (". + ") @ (\ [[0-9] {1 a-zA-Z 3}\. [0-9] {1 a-zA-Z 3}\. [0-9] {1 recol 3}\. [0-9] {1 Magne3}]) | ([0-0-9] +\.) + [a-zA-Z] {2 }) $/ gi// has unreliably tested that the mailbox formats of these writing methods have all passed / / cc011@qq.com//fsdlk@dd-fad.cn//df_fs2.q@jd-f.com//crklej-dsfj@132.com//fdfkj@aa_fslkdfj.com.cn//d390.fslk@qq.com//1100@gmail.cn//sflk-98_dsf@qq_fsk.com
Enhanced password setting specification
/ / must contain uppercase and lowercase letters, numbers and special symbols. Length 8~24const regexEnhancePassword = / ^ (?!\ s) ((? =. * [a-zA-Z]) (? =. * [Amurz]) (? =. * [Amurz]) (? =. * [\ W _]).\ S {8pm 24}) $/ g
Verification of Chinese license plate number
Const regexCarLicense = / ^ [Beijing, Tianjin, Shanghai, Chongqing, Hebei, Henan, Yunnan, Yunnan, Henan, black, Hunan, Anhui, Shandong, new Jiangsu, Zhejiang, Jiangxi, Hubei, Guangxi, Jin, Shaanxi, Fujian, Guizhou, Guangdong, Qinghai, Tibet, Sichuan and Ningqiong] {1} [A-Z0 Z] {1} [A-Z0-9] {4} [A-Z0-9, Hong Kong and Macao] {1} $/ g
Match the QQ number and Wechat number.
/ / QQ seems to have always been a pure number in my impression, but now it seems to have grown to 11 digits. It seems that const regexQQNumber = / ^ [1-9]\ d {5pm 10} $/ gi;//, which started from 100000, specially checked the rules of the latest WeChat account / / 1. WeChat account is the only certificate of Wechat and can only be set once; / / 2, you can use 6-20 letters, numbers, underscores and minus signs. / / 3. Must start with a letter (letters are not case-sensitive); / / 4. Setting Chinese is not supported. Const regexWeChatNumber = / ^ [A-Za-z] [\ w -] {5pm 19} $/ gi
User name specification
/ / ordinary version, English + digits, must begin with letters and allow underscores. Length 8 to 16 Const regexNormalUsername = / ^ [a-zA-Z]\ w {7 gi;// 15} $/ gi;// on this basis allows four to six characters const regexE1 = / ^ [\ u4e00 -\ u9fa5] {4jue 6} $| ^ [a-zA-Z]\ w {7pm 15} $/ gi / / reuse multiple versions, allow mobile phone, mailbox, Chinese, if this is written in one, it would be good to write in groups / / but it is very long, if...else is recommended. To split, just three regularities. The above is all the content of the article "what are the regular expressions commonly used at the front end?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.