Feature | Syntax | Description | Example | .NET | Java | Perl | PCRE | PCRE2 | PHP | Delphi | R | JavaScript | VBScript | XRegExp | Python | Ruby | std::regex | Boost | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | Oracle | XML | XPath |
String anchor |
^ (caret) |
Matches at the start of the string the regex pattern is applied to. |
^. matches a in abc\ndef |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | no | YES |
String anchor |
$ (dollar) |
Matches at the end of the string the regex pattern is applied to. |
.$ matches f in abc\ndef |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | no | YES |
String anchor |
$ (dollar) |
Matches before the final line break in the string (if any) in addition to matching at the very end of the string. |
.$ matches f in abc\ndef\n |
YES | YES | YES | YES | YES | YES | YES | YES | no | no | no | YES | no | no | no | no | no | no | no | no | no | n/a | no |
Line anchor |
^ (caret) |
Matches after each line break in addition to matching at the start of the string, thus matching at the start of each line in the string. |
^. matches a and d in abc\ndef |
option | option | option | option | option | option | option | option | option | option | option | option | YES | YES | basic extended grep egrep awk | option | option | option | option | option | option | n/a | option |
Line anchor |
$ (dollar) |
Matches before each line break in addition to matching at the end of the string, thus matching at the end of each line in the string. |
.$ matches c and f in abc\ndef |
option | option | option | option | option | option | option | option | option | option | option | option | YES | YES | basic extended grep egrep awk | option | option | option | option | option | option | n/a | option |
String anchor |
\A |
Matches at the start of the string the regex pattern is applied to. |
\A\w matches only a in abc |
YES | YES | YES | YES | YES | YES | YES | YES | no | no | no | YES | YES | no | ECMA extended egrep awk | no | no | no | no | no | 10gR2 | no | no |
Attempt anchor |
\A |
Matches at the start of the match attempt. |
\A\w matches a , b , and c when iterating over all matches in abc def |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | no | no | no | no | no | no | no |
Attempt anchor |
\G |
Matches at the start of the match attempt. |
\G\w matches a , b , and c when iterating over all matches in abc def |
no | no | no | 4.0–7.9 | no | YES | YES | YES | no | no | no | no | YES | no | no | no | no | no | no | no | no | no | no |
Match anchor |
\G |
Matches at the end of the previous match during the second and following match attempts. Matches at the start of the string during the first match attempt. |
\G\w matches a , b , and c when iterating over all matches in abc def |
YES | YES | YES | 8.00 | YES | no | no | no | no | no | no | no | no | no | ECMA extended egrep awk | no | no | no | no | no | no | no | no |
String anchor |
\z |
Matches at the end of the string the regex pattern is applied to. |
\w\z matches f in abc\ndef but fails to match abc\ndef\n |
YES | YES | YES | YES | YES | YES | YES | YES | no | no | no | no | YES | no | ECMA extended egrep awk | no | no | no | no | no | 10gR2 | no | no |
String anchor |
\Z |
Matches at the end of the string the regex pattern is applied to. |
\w\Z matches f in abc\ndef but fails to match abc\ndef\n or abc\ndef\n\n |
no | no | no | no | no | no | no | no | no | no | no | YES | no | no | no | YES | no | no | no | no | no | no | no |
String anchor |
\Z |
Matches at the end of the string as well as before the final line break in the string (if any). |
.\Z matches f in abc\ndef and in abc\ndef\n but fails to match abc\ndef\n\n |
YES | YES | YES | YES | YES | YES | YES | YES | no | no | no | no | YES | no | no | no | no | no | no | no | 10gR2 | no | no |
String anchor |
\Z |
Matches at the end of the string as well as before all trailing line breaks in the string (if any). |
.\Z matches f in abc\ndef and in abc\ndef\n and in abc\ndef\n\n |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | ECMA extended egrep awk | no | no | no | no | no | no | no | no |
String anchor |
\` (backslash backtick) |
Matches at the start of the string the regex pattern is applied to. |
\`\w matches only a in abc |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | ECMA extended egrep awk | no | no | no | no | no | no | no | no |
Attempt anchor |
\` (backslash backtick) |
Matches at the start of the match attempt. |
\`\w matches a , b , and c when iterating over all matches in abc def |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | YES | no | no | no |
String anchor |
\' (backslash quote) |
Matches at the end of the string the regex pattern is applied to. |
\w\' matches f in abc\ndef but fails to match abc\ndef\n |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | ECMA extended egrep awk | no | no | no | YES | YES | no | no | no |
Feature | Syntax | Description | Example | .NET | Java | Perl | PCRE | PCRE2 | PHP | Delphi | R | JavaScript | VBScript | XRegExp | Python | Ruby | std::regex | Boost | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | Oracle | XML | XPath |
---|