Sample Regular Expressions |

Expression | Meaning
^abc | Match "abc" at beginning of line
abc$ | Match "abc" at end of line
^abc$ | Match the line "abc" exactly
^\s*abc | Match "abc" at beginning of line, but allow leading whitespace
^\s*end;?\s*$ | Match a line containing only "end" or "end;" with leading or trailing whitespace
abc|def | Matches either "abc" or "def"
a(b|c)d | Matches "abd" or "acd"
a(b|c)d\1 | Matches "abdb" or "acdc", but it does not match "abdc"

Control characters used in above samples

Character | Meaning
^ | Beginning of line
$ | End of line
\s | Whitespace (a tab or space)
* | Zero or more of the preceding character
? | Preceding character is optional
| | Alternative expression
( ) | Subexpressions
\1 | Back reference to 1st subexpression

See also

Regular Expression Reference