Single Character
Special Character | RE | Description |
---|---|---|
New line | \n | New line |
Next page | \f | Form feed |
Return | \r | return |
space | \s | space |
table | \t | table |
Vertical table | \v | Vertical tab |
back | [\b] | Backspace |
Multi-Character
Special Character | RE | Description |
---|---|---|
Any character except new line | . | |
[0-9], single number | \d | digit |
Except [0-9] | \D | Not digit |
[A-Z,a-z,0-9] | \w | Word |
except [A-Z,a-z,0-9] | \W | Not word |
Matches Unicode whitespace characters | \s | |
any character which is not a whitespace character | \S | Not space |
loop and repeat
0|1
?
Means match 0 or 1 character. Like color
and colour
, our regular expression is: /colou?r/
>=0
Use *
, means 0 or infinity character(s).
>=1
+