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 matching detects various numerical types

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

Share

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

This article introduces the knowledge of "JS regular expression matching detection of various numerical types". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

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: ^\ w + [- +.]\ w +) * @\ w + ([-.]\ w +) *.\ w + ([-.]\ w +) * $

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

Verify the phone number: ^ (\ (\ d {3pr 4}\) |\ d {3pr 4} -)?\ d {7J 8} $:-- the 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 +)? $

This is the end of "JS regular expression matching Detection of various numerical types". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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