Special Characters in Regular Expressions describes the special characters and provides examples.
<\/a> interprets the forward slash literally in the end HTML anchor tag.
\n matches a newline character.
|
|
^apple matches “apple” at the beginning of a string.
|
|
apple$ matches “apple” at the end of a string.
|
|
.apple matches any single character and then “apple”.
|
|
(apple|orange|banana) matches “apple”, “orange”, or “banana”.
|
|
apple (pie)? matches one or more instances of “pie”.
|
|
(apple|orange|banana) matches “apple”, “orange”, or “banana”.
^(\w+) matches the beginning of a line and then one or more word characters.
|
|
[\s] matches a whitespace character or a digit.
[a-z0-9] matches “a” through “z” and numbers “0” through “9”.
|
|
apple{3} repeats three times.
apple{3,} repeats at least three times as many times as possible.
apple{3, 10} repeats three times but no more than 10 times.
Append a question mark to indicate repeating as few times as possible. For example, apple{3,}? repeats at least three times as few times as possible.
|