Commonly used regular expression table (concise and no nonsense)

Operator Description Instance
. Represents any single character  
[ ] Character set, giving a range of values ​​for a single character [abc] means a, b, c, [az] means a to z single character
[^ ] Non-character set, the exclusion range is given for a single character [^abc] means a single character other than a or b or c
* Extend the previous character 0 times or unlimited times abc* means ab, abc, abcc, abccc, etc.
+ Extend the previous character 1 time or unlimited times abc+ means abc, abcc, abccc, etc.
0 or 1 expansion of the previous character abc? means ab, abc
| Any one of left and right expressions abc|def means abc, def
{m} Extend the previous character m times ab{2}c means abbc
{m,n} Extend the previous character m to n times (including n) ab{1,2}c means abc, abbc
^ Match the beginning of the string ^abc means abc and is at the beginning of a string
$ Match end of string abc$ means abc and is at the end of a string
( ) Grouping mark, only the | operator can be used internally (abc) means abc, (abc|def) means abc, def
\\d Number, equivalent to [0-9]  
\\w Word character, equivalent to [A-Za-z0-9_]  

 

Guess you like

Origin blog.csdn.net/weixin_43158695/article/details/112648060