正则表达式快查笔记
正则表达式快查笔记 #
下表来源于RegexOne,这是一个可供练习的学习正则表达式的网站。
| 例子 | 描述 |
|---|---|
| abc… | 精确匹配字母 |
| 123… | 精确匹配数字 |
| \d | 匹配任意数字 |
| \D | 匹配任意非数字字符 |
| . | 匹配任意字符 |
| . | 匹配英文句号"." |
| [abc] | 匹配a,b,c中的任意一个 |
| [^abc] | 不匹配a,b,c中的任意一个 |
| [a-z] | 匹配字母a到z |
| [0-9] | 匹配数字0-9 |
| \w | Any Alphanumeric character |
| \W | Any Non-alphanumeric character |
| {m} | m Repetitions |
| {m,n} | m to n Repetitions |
| * | Zero or more repetitions |
| + | One or more repetitions |
| ? | Optional character |
| \s | Any Whitespace |
| \S | Any Non-whitespace character |
| ^…$ | Starts and ends |
| (…) | Capture Group |
| (a(bc)) | Capture Sub-group |
| (.*) | Capture all |
| (abc|def) | Matches abc or def |