In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use metacharacters about JavaScript regularization. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Metacharacters:
Every regular expression is made up of metacharacters and modifiers
[metacharacters]-> meaningful characters between two /
Reg = / ^\ dflowers / can only be a number between 0 and 9
1. Metacharacters with special meaning
\: escape characters, translating the meaning represented by the following characters
^: start with a metacharacter
$: ends with a metacharacter
\ n: matches a newline character
. : any character except\ n
(): grouping-> dividing a large regular itself into several small regularities
X | y: X or one of y
[xyz]: one of x or y or z
[^ xyz]: any character except three
[amurz]: any character between amerz
[^ amurz]: except for any character between amurz
\ d: a character between 0 and 9\ D any character except a number between 0 and 9
\ b: a boundary character "W1 w2 w3"
\ w: any character in a number, letter, or underscore [0-9aMuz Amurz]
\ s: matches a blank character space, a tab, a feed character.
2. Quantifier metacharacters that represent the number of occurrences
*: zero to multiple occurrences
+: appear 1 to multiple times
? : zero or one occurrence
{n}: appear n times
{n,}: n to multiple times
{nrecoery m}: appear n to m times
Var reg = / ^\ d+wo\ dcharacters / 123wo234 var reg = / ^ (\ d+) wo (\ d+) $/; var reg = / ^ 0.20 $/ / ends with 0, with any character var reg = / ^\ dcards / except\ n in the middle / / can only be multiple digits console.log (reg.test ('2017')) / / true / / A simple regular verification of the mobile phone number: 11 digits, the first digit is 1 var reg = / ^ 1\ d {10} $/
Second, metacharacter application
[]
1. All characters that appear in square brackets are characters that represent their own meaning (with no special meaning).
()
1. The function of grouping: change the default priority of x | y
Var reg = / ^ 18 | 19 $/; / / those eligible are 189,119,819, 1819 var reg = / ^ (18 | 19) $/ / 188,19
1. Regular positive, negative, zero and decimal numbers of significant numbers
1), ". It may or may not appear, but once it does, it must be followed by one or more digits.
2) at the beginning, there can be + /-or not.
3) in the part of integers, one digit can be between 0 and 9, and multiple digits cannot start with 0
The rules are as follows
Var reg = / ^ [+ -]? (\ d | ([1-9]\ d +)) (\.\ d +)? $/ about "how to use metacharacters of JavaScript regularity" is shared here. 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, please 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.