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

JS regular expression validates the complete Book of numbers

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

Share

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

This article mainly explains the "JS regular expression verification numbers Daquan", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "JS regular expression verification numbers Daquan" bar!

Regular expression (regular expression) describes a pattern of string matching, which can be used to check whether a string contains a certain substring, replace a matching substring, or extract a substring from a string that meets a certain condition.

Take a look at the js code first, as shown below:

Function SubmitCk () {var reg = / ^ ([a-zA-Z0-9] + [_ |\ _ |\.]?) * [a-zA-Z0-9] + @ ([a-zA-Z0-9] + [_ |\.]?) * [a-zA-Z0-9] +\. [a-zA-Z] {2 txtEmail 3} $/; if (! reg.test ($("# txtEmail"). Val ()) {alert ("Please enter the correct email address") return false }}

Validate the set of regular expressions for numbers

Verification number: ^ [0-9] * $

Verify the n-digit number: ^\ d {n} $

Verify at least n digits: ^\ d {n,} $

Verify the number of mmurn digits: ^\ d {mcentine n} $

Verify zero and non-zero numbers: ^ (0 | [1-9] [0-9] *) $

Verify the positive real number with two decimal places: ^ [0-9] + (. [0-9] {2})? $

Verify a positive real number with 1-3 decimal places: ^ [0-9] + (. [0-9] {1Jue 3})? $

Verify non-zero positive integers: ^\ +? [1-9] [0-9] * $

Verify non-zero negative integers: ^\-[1-9] [0-9] * $

Verify that non-negative integers (positive integers + 0) ^\ dflowers $

Verify non-positive integer (negative integer + 0) ^ ((-\ d +) | (0 +)) $

Verify a character of length 3: ^. {3} $

Verify the 26-letter string: ^ [A-Za-z] + $

Verify the string of 26 uppercase letters: ^ [Amurz] + $

Verify the string of 26 lowercase letters: ^ [amurz] + $

Verify the string consisting of numbers and 26 letters: ^ [A-Za-z0-9] + $

Verify a string consisting of numbers, 26 letters, or an underscore: ^\ wicked $

Verify the user password: ^ [a-zA-Z]\ w {5pm 17} $is in the correct format: begins with a letter, is between 6 and 18 in length, and can only contain characters, numbers, and underscores.

Verify whether it contains characters such as ^% &',; =? $\ ": [^% &',; =? $\ x22] +

Verify Chinese characters: ^ [\ u4e00 -\ u9fa5], {0,} $

Verify the Email address: / ^ ([a-zA-Z0-9] + [_ |\ _ |\.]?) * [a-zA-Z0-9] + @ ([a-zA-Z0-9] + [_ |\.]?) * [a-zA-Z0-9] +\. [a-zA-Z] {2jue 3} $/

Verify InternetURL: ^ http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$; ^ [a-zA-z] +: / / (w + (- w +) *) (. (W + (- w +) *)) * (? S*)? $

Verify the phone number: ^ (\ d3Power4 |\ d {3re4} -)?\ d {7pc8} $:-- correct format is: XXXX-XXXXXXX,XXXX-XXXXXXXX,XXX-XXXXXXX,XXX-

XXXXXXXX,XXXXXXX,XXXXXXXX .

Verify ID number (15 or 18 digits): ^\ d {15} |\ d {} 18 $

Verify that the 12 months of the year: ^ (0? [1-9] | 1 [0-2]) $is in the correct format: "01"-"09" and "1"12"

Verify the 31 days of a month: ^ ((0? [1-9]) | (1 | 2) [0-9]) | 30 | 31) the correct format is: 01, 09 and 1, 31.

Integer: ^ -?\ dbath $

Non-negative floating point number (positive floating point number + 0): ^\ d + (\.\ d +)? $

Positive floating point number ^ (([0-9] +. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] *. [0-9] +) | ([0-9] * [1-9] [0-9] *)) $

Non-positive floating point number (negative floating point number + 0) ^ ((-\ d + (\.\ d +)?) | (0 + (\ .0 +)?)) $

Negative floating point number ^ (- ([0-9] +\. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] *. [0-9] +) | ([0-9] * [1-9] [0-9] *)) $

Floating point number ^ (-?\ d +) (\.\ d +)? $

Thank you for your reading, the above is the content of "JS regular expression verification digits". After the study of this article, I believe you have a deeper understanding of the problem of JS regular expression verification numbers, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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