Flags
imake the pattern case insensitive
gsearch for every occurence of the matching pattern
Position Characters
^pattern must be at the start of the text string
$pattern must be at the end of the text string
\bmatch a position that is a word boundary (the point between a word character and a non-word character
\Bmatch a position that is not a word boundary
Character Classes
\dmatch any digit 0-9
\Dmatch any character that is not a digit
\wmatch any word character (0-9, A-Z, a-z, or _ )
\Wmatch any non-word character
\smatch any whitespace character (space, tab, newline, carriage return, form feed)
\Smatch any non-whitespace character
.match any character
Character Classes
[chars]match any characters (chars) within the brackets
[^chars]match any character except those within the brackets (chars)
[char1-charN]match characters in the range char1 through charN
[^char1-charN]do not match characters in the range char1 through charN
Repetition Characters
*repeat zero or more times
?repeat zero or one time
+repeat one or more times
{n}repeat exactly n times
{n, }repeat at least n times
{n,m}repeat at least n times, but no more than m times
Escape Sequences
\/match a /
\\match a \
\.match a .
\*match a *
\+match a +
\?match a ?
\|match a |
\(match a (
\)match a )
\{match a {
\}match a }
\^match a ^
\$match a $
\nmatch a new line
\rmatch a carriage return
\tmatch a tab
Alternative and Grouping Characters
chars1|chars2match either the chars1 or chars2 character patterns
(chars)group the character pattern char and treat it as a single unit. Matched groups are captured and available for later procession as back-reference
\nthe back-reference to group n
(?chars)group the character pattern char and treat it as a single unit. Matched groups are not back-referenced