| 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Word boundary | \b | Matches at a position that is followed by a word character but not preceded by a word character, or that is preceded by a word character but not followed by a word character. | \b. matches a, , and d in abc def | Unicode | 3.0 Unicode 2.4 ASCII | ASCII | ASCII | ASCII | non‑ECMA Unicode | ASCII | Unicode | default ASCII | Unicode | ASCII | ASCII | Unicode | ASCII | ASCII | 1.9 Unicode 1.8 ASCII | ECMA ASCII | ECMA extended egrep awk Unicode | no | no | ASCII | no | no | no |
| Word non-boundary | \B | Matches at a position that is preceded and followed by a word character, or that is not preceded and not followed by a word character. | \B. matches b, c, e, and f in abc def | Unicode | 3.0 Unicode 2.4 ASCII | ASCII | ASCII | ASCII | non‑ECMA Unicode | ASCII | Unicode | default ASCII | Unicode | ASCII | ASCII | Unicode | ASCII | ASCII | 1.9 Unicode 1.8 ASCII | ECMA ASCII | ECMA extended egrep awk Unicode | no | no | ASCII | no | no | no |
| Tcl word boundary | \y | Matches at a position that is followed by a word character but not preceded by a word character, or that is preceded by a word character but not followed by a word character. | \y. matches a, , and d in abc def | Unicode | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | no | no | no |
| Tcl word non-boundary | \Y | Matches at a position that is preceded and followed by a word character, or that is not preceded and not followed by a word character. | \Y. matches b, c, e, and f in abc def | Unicode | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | no | no | no |
| Tcl word boundary | \m | Matches at a position that is followed by a word character but not preceded by a word character. | \m. matches a and d in abc def | Unicode | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | no | no | no |
| Tcl end-of-word boundary | \M | Matches at a position that is preceded by a word character but not followed by a word character. | .\M matches c and f in abc def | Unicode | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | no | no | no |
| GNU word boundary | \< | Matches at a position that is followed by a word character but not preceded by a word character. | \<. matches a and d in abc def | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | ECMA extended egrep awk Unicode | no | no | ASCII | no | no | no |
| GNU end-of-word boundary | \> | Matches at a position that is preceded by a word character but not followed by a word character. | .\> matches c and f in abc def | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | ECMA extended egrep awk Unicode | no | no | ASCII | no | no | no |
| POSIX word boundary | [[:<:]] | Matches at a position that is followed by a word character but not preceded by a word character. | [[:<:]]. matches a and d in abc def | no | no | no | no | no | no | no | no | no | no | 8.34 ASCII | ASCII | 5.5.10 Unicode | XE7 ASCII | 3.0.3 ASCII | no | no | Unicode | Unicode | ASCII | no | no | no | no |
| POSIX end-of-word boundary | [[:>:]] | Matches at a position that is preceded by a word character but not followed by a word character. | .[[:>:]] matches c and f in abc def | no | no | no | no | no | no | no | no | no | no | 8.34 ASCII | ASCII | 5.5.10 Unicode | XE7 ASCII | 3.0.3 ASCII | no | no | Unicode | Unicode | ASCII | no | no | no | no |
| Word boundary behavior | Word boundaries always match at the start of the match attempt if that position is followed by a word character, regardless of the character that precedes the start of the match attempt. (Thus word boundaries are not handled correctly for the second and following match attempts in the same string.) | \b. matches all of the letters but not the space when iterating over all matches in the string abc def | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | no | YES | no | no | no | |
| UAX 29 word boundary | \b and \B | Matches at a word boundary ÷ and \B matches at a word non-boundary × according to Unicode Standard Annex #29. | \b.\b matches ! because the WB1 and WB2 rules in UAX 29 treat the start and end of the string as a word boundary. | no | no | no | no | no | no | no | option | no | no | no | no | no | no | no | no | no | no | n/a | n/a | no | n/a | n/a | n/a |
| UAX 29 word boundary | \b{wb} | Matches at a word boundary ÷ according to Unicode Standard Annex #29. | \b{wb}.\b{wb} matches ! because the WB1 and WB2 rules in UAX 29 treat the start and end of the string as a word boundary. | no | no | no | no | no | no | no | no | no | 5.22 | no | no | no | no | no | no | no | no | no | no | no | no | no | no |
| UAX 29 word non-boundary | \b{wb} | Matches at a word non-boundary × according to Unicode Standard Annex #29. | \B{wb}'\B{wb} matches ' in John's because the WB6 and WB7 rules in UAX 29 treat the positions before and after a hyphen between two letters as a word non-boundary. | no | no | no | no | no | no | no | no | no | 5.22 | no | no | no | no | no | no | no | no | no | no | no | 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/refwordboundaries.html
Page last updated: 10 June 2025
Site last updated: 18 August 2026
Copyright © 2003-2026 Jan Goyvaerts. All rights reserved.