This time I will bring you the method of fast memory of js regular. What are the precautions for fast memory of js regular. The following is a practical case, let’s take a look.
We know thatregular expressions is a very practical technique in processing strings. However, even programmers who are very good at writing Javascript sometimes forget the syntax of regular expressions, making it a bit tricky to use
1. The three most important symbols in regular expressions1.1 B
There are 3 types of brackets in B in regular expressions: 1.1.1 Square brackets “[“. Square brackets "[" contain the characters that need to be matched. Content enclosed in square brackets matches only a single character. ^[ab]$ 1.1.2 Curly brackets "{" The curly braces "{" specify the number of matching characters. ^[ab]{3}$ 1.1.3 Parentheses “(“ Parentheses "(" are used for grouping. ^(ab)$ 1.2 C The caret "^" indicates the beginning of the regular expression. ^a When ^ is used at the beginning of square brackets, it means to exclude the characters in the brackets. ^[^0-9]$ 1.3 $ The dollar sign "$" indicates the end of the regular expression. com$2. Regular expression verification
Recommend a URL to verify regular expressions:https://regexper.com/
2.1 Example ^[0-9]{3,7}$ The above regular expression is a number with a minimum length of 3 and a maximum length of 7. 2.2 The '│' symbol is equivalent to the OR operation ^(1|2)$3. Shortcut commands
3.1 d represents a number [0-9]. Note that there is an escape character before d. ^d$ Capital D: D represents non-digit ^D$ 3.2 Any word character underline w ^w$ Capital W: W represents non-word ^W$ 3.3 0 or more occurrences * ^[0-9]*$ 3.4 Occurs at least once ^[0-9] $ 3.5 0 or 1 occurrence? ^[0-9]?$I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:How to switch between Chinese and English in the navigation bar with js
JS to achieve chessboard coverage
JSprototype object usage tutorial
The above is the detailed content of js regular fast memory method. For more information, please follow other related articles on the PHP Chinese website!