In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use regular verification mobile phone number, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to know it.
Only numbers are allowed to be entered
Value=value.replace (/ [^\ d] / GMagneur') clipboardData.setData ('text',clipboardData.getData (' text'). Replace (/ [^\ d] / GMagazine')) / / as long as you fill in a landline phone, you can get $('.form-inline') .submit (function () {var m = $(' var [name = phone]'). Val (); var p = $('input [name = phone]'). Val (); var reg = / ^ 1\ d {10} $/ If ((m = "| |! reg.test (m)) & & p = =") {$('input [name = mobile]'). AddClass ('error_color'); $(' input [name = mobile]'). Tooltip ('show'); return false;} else {$(' input [name = mobile]'). RemoveClass ('error_color'); $(' input [name = mobile]'). Tooltip ('hide'); return true })
Let's take a look at the latest mobile phone number verification regular expression.
Due to the continuous updating of the mobile phone number range, the previous regular expression has been unable to meet the demand. Rewrite this expression, the source of the number segment is based on: http://www.jihaoba.com/tools/haoduan/
Existing mobile phone number range:
Mobile: 139 138 137 136 135 134 147 150 151 152 157 159 178 182 183 184 187 188
China Unicom: 130 131 132 155 156 185 186 145 176
Telecom: 133 153 177 173 180 181 189
Virtual operator:
170 171
After finishing:
130,000,139 145147 15 [012356789] 1781761771731701717188176177173170171 180188176177173170171731701717317017317017173170173170173173170171881761771731701717317017188176177173170171 188176177173170171 188176177173170170188176177173170171 1801881761771731701731701731731701731781761771731701701881761771731701701881761771731701717317017
Var regex = {mobile: / ^ 0? (13 [0-9] | 15 [012356789] | 17 [013678] | 18 [0-9] | 14 [57]) [0-9] {8} $/}
Js:
Var bool = checkRegexp (jq ("# mobile"), / ^ 0? (13 [0-9] | 15 [012356789] | 17 [013678] | 18 [0-9] | 14 [57]) [0-9] {8} $/, "incorrect phone format")
Expression parsing:
"/" represents a regular expression.
"^" represents the beginning of the string, and "$" represents the end of the string.
"?" It means to match one or zero of the preceding characters, so here 0? It means that the mobile phone number can start with 0 or not.
The next part verifies the 11-digit mobile phone number, starting from 13, because the optional range from 130 to 139 is [0-9], and the number that begins with 15 does not have 154, so there is no 4 in [], of course, it can also be written as [0-35-9]. The numbers opened by 18 and 14 below are the same as above.
The parentheses represent a subexpression in which four optional branches are distinguished by "|". In the rule, the priority of "|" is the lowest. Here, each branch matches 3 characters (a [] can only match one character, which means optional), that is, the first three digits of the mobile phone number, so there are still 8 digits to match. It can be any character of 0-9, so it is "[0-9] {8}", and the number in {} represents the number of matching previous characters.
Analysis complete.
What if there is a big-headed ghost who writes 86 and 17951 or something in front of him?
/ ^ (0 | 86 | 17951)? (13 [0-9] | 15 [012356789] | 17 [013678] | 18 [0-9] | 14 [57]) [0-9] {8} $/
C # version:
Using System.Text.RegularExpressions; public static bool IsTelephone (string str_telephone) {return Regex.IsMatch (str_telephone, @ "^ (0 | 86 | 17951)? (13 [0-9] | 15 [012356789] | 17 [013678] | 18 [0-9] | 14 [57]) [0-9] {8} $") } Thank you for reading this article carefully. I hope the article "how to use regular Verification Mobile phone number" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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
The book recommended by the teacher when listening to acp's preaching.
© 2024 shulou.com SLNews company. All rights reserved.