Regular expression summary
Search pattern
? |
zero or one of previous, {0,1} |
be?t |
* |
zero or more of previous, maximal, {0,} |
b.*t |
*? |
zero or more of previous, minimal, {0,}? |
b.*?t |
+ |
one or more of previous, maximal, {1,} |
b.+t |
+? |
one or more of previous, minimal, {1,}? |
b.+?t |
{n} |
n times of previous |
be{n}t |
{n,} |
n or more times of previous, maximal |
b.{n,}t |
{n,}? |
n or more times of previous, minimal |
b.{n,}?t |
{n,m} |
n to m times of previous |
be{1,2}t |
. |
any character |
b.t |
[] |
any one character in a class |
[a-m] |
[^] |
any one not in a character class |
[^a-m] |
[\b] |
one backspace character |
my[\b]word |
\d |
any one digit, [0-9] |
file\d |
\D |
any one not digit, [^0-9] |
file\D |
\s |
any one white space character, [ \t\n\r\f\v] |
my\sword |
\S |
any one not white space character, [^ \t\n\r\f\v] |
my \sord |
\w |
any one word character, [a-zA-Z0-9_] |
my big\w |
\W |
any one not word character, [^a-zA-Z0-9_] |
my\Wbig |
^ |
anchor to start of string |
^string |
$ |
anchor to end of string |
string$ |
\b |
anchor to word boundary |
\bbig |
\B |
anchor to not word boundary |
\Bbig |
| |
or |
(bat)|(bet) |
\n |
group n |
(bat)a\1 |
() |
group |
my(.?)fil |
(?:) |
group without capture |
my(?:.?)fil |
(?=) |
group without capture with positive look ahead |
my(?=.?)fil |
(?!) |
group without capture with negative look ahead |
my(?!.?)fil |
\f |
form feed character |
string\f |
\n |
newline |
string\n |
\r |
carriage return character |
string\r |
\t |
horizontal tab character |
one\tfour |
\v |
vertical tab character |
one\vtwo |
\/ |
/ character |
\/fil |
\\ |
\ character |
\\fil |
\. |
. character |
fil\.bak |
\* |
* character |
one\*two |
\+ |
+ character |
\+fil |
\? |
? character |
when\? |
\| |
| character |
one\|two |
\( |
( character |
\(fil\) |
\) |
) character |
\(fil\) |
\[ |
[ character |
\[fil\] |
\] |
] character |
\[fil\] |
\{ |
{ character |
\{fil\} |
\} |
} character |
\{fil\} |
\C |
a character itself. Seldom used. |
b\at |
\cC |
a control character |
one\cIfour |
\x## |
character by hexadecimal code |
\x41 |
\### |
character by octal code |
\101 |
Replace pattern
$n |
group n in search pattern, $1, $2, . . . $9 |
big$1 |
$+ |
last group in search pattern |
big$+ |
$` |
text before matched pattern |
big$` |
$' |
text after matched pattern |
big$' |
$& |
text of matched pattern |
big$& |
\$ |
$ character |
big\$ |
Regular expression repetition characters