In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to remember JavaScript regular expressions. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
We know that regular expressions are a practical technique for dealing with strings. However, even programmers who are very good at Javascript sometimes forget the syntax of regular expressions, making it a bit tricky to use
1. The three most important symbols in regular expressions:
1.1 B
B has three types of parentheses in regular expressions:
1.1.1 square brackets "[".
Inside the square brackets "[" are the characters to be matched. The content enclosed in brackets matches only a single character.
^ [ab] $
1.1.2 curly braces "{"
Within the curly braces "{" is the specified number of matching characters.
^ [ab] {3} $
1.1.3 parentheses "("
Parentheses "(" are used for grouping.
^ (ab) $
1.2 C
The insert symbol "^" indicates the beginning of the regular expression.
^ a
When used at the beginning of square brackets, it means to exclude the characters in parentheses.
^ [^ 0-9] $
1.3 $
The dollar sign "$" indicates the end of the regular formula.
Com$
2. Regular expression verification
Recommend a URL to validate regular expressions: https://regexper.com/
2.1 exampl
^ [0-9] {3pm 7} $
The above regular expression is a number with a minimum length of 3 and a maximum of 7.
The verification results are as follows:
2.2 '│' symbol is equivalent to OR operation
^ (1 | 2) $
3. Shortcut command
3.1\ d represents a number [0-9] Note that d is preceded by an escape character\
^\ d$
Capital D:\ D means non-numeric
^\ D$
3.2 any word character underlined\ w
^\ w $
Uppercase W:\ W for non-words
^\ W$
3.30 or more times *
^ [0-9] * $
3.4 at least one occurrence +
^ [0-9] + $
3.50 times or 1 time?
^ [0-9]? $
Thank you for reading! This is the end of this article on "how to remember JavaScript regular expressions". 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, you can 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.
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.