RegexBuddy Get RegexBuddy to instantly and accurately analyze and test any regular expression taking into account all the features and limitations of your chosen regex flavor.

Regular Expression Reference: Anchors

FeatureSyntaxDescriptionExample JGsoft .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 YESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESnoYES
String anchor $ (dollar) Matches at the end of the string the regex pattern is applied to. .$ matches f in abc\ndef YESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESnoYES
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 YESYESYESYESYESYESYESYESYESnononoYESnononononononononon/ano
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 YESoptionoptionoptionoptionoptionoptionoptionoptionoptionoptionoptionoptionYESYESbasic
extended
grep
egrep
awk
optionoptionoptionoptionoptionoptionn/aoption
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 YESoptionoptionoptionoptionoptionoptionoptionoptionoptionoptionoptionoptionYESYESbasic
extended
grep
egrep
awk
optionoptionoptionoptionoptionoptionn/aoption
String anchor \A Matches at the start of the string the regex pattern is applied to. \A\w matches only a in abc YESYESYESYESYESYESYESYESYESnononoYESYESnoECMA
extended
egrep
awk
nonononono10gR2nono
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 nonononononononononononononononoYESnonononononono
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 YESnonono4.0–7.9noYESYESYESnonononoYESnononononononononono
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 noYESYESYES8.00YESnononononononononoECMA
extended
egrep
awk
nononononononono
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 YESYESYESYESYESYESYESYESYESnonononoYESnoECMA
extended
egrep
awk
nonononono10gR2nono
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 nonononononononononononoYESnononoYESnonononononono
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 YESYESYESYESYESYESYESYESYESnonononoYESnonononononono10gR2nono
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 nononononononononononononononoECMA
extended
egrep
awk
nononononononono
String anchor \` (backslash backtick) Matches at the start of the string the regex pattern is applied to. \`\w matches only a in abc nononononononononononononononoECMA
extended
egrep
awk
nononononononono
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 nononononononononononononononononononoYESYESnonono
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 nononononononononononononononoECMA
extended
egrep
awk
nononoYESYESnonono
FeatureSyntaxDescriptionExample JGsoft .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

Make a Donation

Did this website just save you a trip to the bookstore? Please make a donation to support this site, and you'll get a lifetime of advertisement-free access to this site!

Quick Start | Tutorial | Tools & Languages | Examples | Reference | Book Reviews |

Introduction | Table of Contents | Quick Reference | Characters | Basic Features | Character Classes | Shorthands | Anchors | Word Boundaries | Quantifiers | Unicode | Capturing Groups & Backreferences | Named Groups & Backreferences | Special Groups | Mode Modifiers | Recursion & Balancing Groups |

Characters | Matched Text & Backreferences | Context & Case Conversion | Conditionals |