In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What are the functions of regular expressions in JavaScript? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Read the catalogue
Creation of regular expressions
Special characters in regular expressions
\ (backslash)
^
$
*, +,. (decimal point)
? (question mark)
(x)
(X)
X (? = y), x (?! y), x | y
{n}, {n,m}:
[xyz], [^ xyz]
Other
Regular expression flag
Regular expressions use the
Most of the time, I will be confused by regular expressions. Recently, I have taken the time to study regular expressions systematically, as follows:
Creation of regular expressions
There are two ways, one is to write directly, which consists of patterns contained between slashes, and the other is to call the constructor of the RegExp object.
The creation code for the two methods is as follows:
/ / directly create const regex1 = / ab+c/;const regex2 = / ^ [a-zA-Z] + [0-9] *\ Wholeships. / call the constructor const regex3 = new RegExp ('ab+c'); const regex4 = new RegExp (/ ^ [a-zA-Z] + [0-9] *\ Whampodash, "gi"); const regex5 = new RegExp (' ^ [a-zA-Z] + [0-9] *\ Wholeships, 'gi')
As you can see, when you call the RegExp constructor to create a regular expression, the first parameter can be a string or a regular expression created directly.
It should be noted that both the toLocaleString () and toString) () methods inherited by the RegExp instance return the literal amount of the regular expression, regardless of how the regular expression is created.
For example:
Const ncname ='[a ncname ZZ] [\\ w\ -\\] *'; const qnameCapture ='((?:'+ ncname +'\:)?'+ ncname +')'; const startTagOpen = new RegExp ('^
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.