Regular Expressions |
Operator |
Description |
Example |
Matches |
Fails |
. |
Any one character except newline |
. |
k |
|
^ |
Start of string |
^T |
^Train |
Car |
$ |
End of string |
t$ |
Artist |
Train |
[chars] |
Any character between the square brackets |
[xyzXYZ] |
Y |
A |
[char range] |
Any character in the range |
[a-zA-Z] |
R |
8 |
\d |
Any single numeric digit. Shortcut for [0-9] |
\d\d\d |
456 |
Car |
\w |
Any alphanumeric character or underscore. Shortcut for [a-zA-Z0-9_] |
\w\w\w |
Bus |
60% |
\s |
Space |
\d\s\d |
1 3 |
123 |
* |
Previous charcter may occur zero or more times. |
joy*car |
jocar |
jcar |
+ |
Previous charcter may occur once or more times |
joy+car |
joyycar |
car |
? |
Previous charcter may occur once or not at all |
boats? |
boat |
boa |
{number} |
Number of repititions of previous character or string.
Curly brackets around number |
\d{3}   (Hi J.){2} |
456   Hi J.Hi J. |
45 34
 Hi K. |