Regular Expression

A regular expression is a text string in which some characters can have special meanings. The characters that have special meaning are:

Character Meaning
^ Matches start of string.
$ Matches end of string.
. Matches any character.
\ Escape character. Causes the next character to have its ordinary meaning. For example, the regular expression \.. matches .a and .2 and any other two-character string that begins with a period.
* Matches zero or more instances of the preceding character. For example, ba* matches b, ba, baa, etc.
+ Matches one or more instances of the preceding character. For example, ba+ matches ba, baa, etc.
[] Indicates a set of characters that can match the current character. A hyphen can be used to indicate a range of characters. For example, [a-zA-Z0-9_]+ matches foo_bar1 but not foo$bar. A ^ indicates a match when the current character is not one of the following characters. For example, [^0-9] matches any character that is not a digit.
\w Matches a word character (same as [a-z_A-Z0-9]).
\W Matches a nonword character (same as [^a-z_A-Z0-9]).
\d Matches a digit (same as [0-9]).
\D Matches a nondigit (same as [^0-9]).
\s Matches white space (same as [ \t\r\n\f]).