Perl Regular Expressions

/abc/
Matches abc anywhere within the string

/^abc/
Matches abc at the beginning of the string

/abc$/
Matches abc at the end of the string

/a|b/
Matches either a or b

/ab{2,4}c/
Matches an a followed by 2-4 b's, followed by c

/ab*c/
Matches an a followed by zero or more b's, followed by c

Expressions are greety- it will match as many as possible. Same as /ab{0,}c/

/ab+c/
Matches an a followed by one or more b's followed by c
Same as /ab{1,}c/

/ab?c/
Matches an a followed by an optional b followed by c
Same as /ab{0,1}c/. This has a different meaning in Perl 5, the expression:
/ab?c/ matches an a followed by as few b's as possible(non-greety)

/./
Matches an single character except a newline (\n)

/[abc]/
A character class-matches any one of the three characters listed. A pattern of /[abc]+/ matches strings such as abcb, acbc, abbac, aaa, abcacbac, ccc, etc.

/\d/
Matches a digit
Same as /[0-9]/
Multipliers can be used (/\d+/ matches one or more digits)

/\w/
Matches a character classified as a word
Same as /[a-zA-Z0-9_]/

/\s/
Matches a character classified as whitespace
Same as /[\r\t\n\f]/

/\b/
Matches a word boundary or a backspace
/test\b/ matches test, but not testing
However, \b matches a backspace character inside a class (ie., [\b])

/[^abc]/
Matches a character that is not in the class
/[^abc]+/will match such strings as hello, test, perl, etc.

/\D/
Matches a charater that is not a digit
Same as /[^0-9]/

/\W/
Matches a character that is not a word
Same as /[^a-zA-Z0-9_]/

/\S/
Matches a character that is not whitespace
Same as /[^ \r\t\n\f]/

/\B/
Requires that there is no word boundary
/hello\B/ matches hello, but not hello there

/\*/
Matches the * character. use the \ character to escape characters that have significance in a regular expression.

/(abc)/
Matches abc anywhere within the string, but the parentheses act as memory, storing abc in the variable $1.
Example:
/name=(.*)&user=\1/ will store zero or more characters after name= in variable $1.

/abc/i
Ignores case. Matches either abc, Abc, ABC, aBc, etc.