Regular Expression, Regular Expression
| Id |
Regex |
Match |
| 1 |
[Abc] |
A, B, or c (simple class) |
| 2 |
[^ Abc] |
Except a, B, or c (NO) |
| 3 |
[A-zA-Z] |
In a to z or A to Z, letters at both ends are included (characters in the range) |
| 4 |
[A-d [m-p] |
Characters from a to d or m to p: [a-dm-p] (union) |
| 5 |
[A-z & [def] |
D, e, or f (intersection) |
| 6 |
[A-z & [^ bc] |
A to z, except for B and c: [ad-z] (minus) |
| 7 |
[A-z & [^ m-p] |
A to z, rather than m to p: [a-SCSI-z] (minus) |
| 8 |
A-zA-Z0-9 + |
Match multiple characters |
| 9 |
\ D |
Number: [0-9] |
| 10 |
\ D |
Non-digit: [^ 0-9] |
| 11 |
\ S |
Blank characters: [\ t \ n \ x0B \ f \ r] |
| 12 |
\ S |
Non-blank characters: [^ \ s] |
| 13 |
\ W |
Word character: [a-zA-Z_0-9] |
| 14 |
\ W |
Non-word characters: [^ \ w] |
In a regular expression, () is used to capture a group. Each group has a number starting from 1, and group zero always represents the entire expression. The captured subsequence can be used in the expression later through \ n (Back Reference, n is the group number. For example, you can use"(.)\\1+"Split strings with overlapping words."."It indicates that any character can be matched,(.)Used to capture a group,\\1Used to obtain captured subsequences,+Indicates one or more.
Ongoing supplements ······