| Replacement Reference |
| Characters |
| Matched Text & Backreferences |
| Case Conversion |
| Context |
| Conditionals |
| Feature | Syntax | Description | Example | JGsoft | Python | JavaScript | VBScript | XRegExp | .NET | Java | ICU | RE2 | Perl | PCRE | PCRE2 | PHP | Delphi | R | Ruby | std::regex | Boost | Tcl | POSIX | GNU | 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 | 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 | 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 | no | no | no | YES | YES | YES | no | YES | YES | YES | YES | YES | YES | no | no | no | no | no | no | YES | 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 | YES | option | option | option | option | option | option | option | option | option | option | option | option | option | option | YES | YES | basic extended grep egrep awk | 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 | YES | option | option | option | option | option | option | option | option | option | option | option | option | option | option | YES | YES | basic extended grep egrep awk | 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 | no | no | no | YES | YES | YES | default | YES | YES | YES | YES | YES | YES | YES | no | ECMA extended egrep awk | no | no | no | YES | 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 | no | no | no | YES | 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 | YES | no | no | no | no | no | no | no | no | no | no | YES | YES | YES | YES | 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 | no | no | no | no | no | YES | YES | YES | no | YES | 8.00 | YES | no | no | no | no | no | ECMA extended egrep awk | 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 | no | no | no | no | YES | YES | YES | default | YES | YES | YES | YES | YES | YES | YES | no | ECMA extended egrep awk | no | no | no | YES | 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 | YES | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | 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 | no | no | no | no | YES | YES | YES | no | YES | YES | YES | YES | YES | YES | YES | no | no | no | no | no | YES | 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 | no | no | no | ECMA extended egrep awk | 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 | no | no | no | ECMA extended egrep awk | 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 | no | no | 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 | no | no | no | ECMA extended egrep awk | no | no | YES | no | no | no |
| Feature | Syntax | Description | Example | JGsoft | Python | JavaScript | VBScript | XRegExp | .NET | Java | ICU | RE2 | Perl | PCRE | PCRE2 | PHP | Delphi | R | Ruby | std::regex | Boost | Tcl | POSIX | GNU | Oracle | XML | XPath |
If you find the content on this website helpful they you may want a copy you can read offline or even print, or browse the site as often as you want without ads. You can purchase your own copy of the Regular-Expressions.info printable PDF download. As a bonus, you'll get a lifetime of advertisement-free access to this site!
| Quick Start | Tutorial | Search & Replace | Tools & Languages | Examples | Reference |
| Introduction | Table of Contents | Quick Reference | Characters | Basic Features | Character Classes | Shorthands | Anchors | Word Boundaries | Quantifiers | Capturing Groups & Backreferences | Named Groups & Backreferences | Special Groups | Unicode Characters and Properties | Unicode Versions | Unicode Categories | Unicode Scripts | Unicode Blocks | Unicode Binary Properties | Unicode Property Sets | Unicode Boundaries | Mode Modifiers | Recursion & Balancing Groups | Backtracking Control Verbs |
| Characters | Matched Text & Backreferences | Case Conversion | Context | Conditionals |
Page URL: https://www.regular-expressions.info/refanchors.html
Page last updated: 9 June 2025
Site last updated: 30 June 2026
Copyright © 2003-2026 Jan Goyvaerts. All rights reserved.