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 |
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 |
non‑ECMA Unicode | ASCII | Unicode | ASCII | ASCII | 5.3.4 Unicode 5.0.0 code page | ASCII | ASCII | ASCII | ASCII | ASCII | 3.0 Unicode 2.4 ASCII | Unicode | ECMA ASCII | ECMA extended egrep awk Unicode | no | no | no | ASCII | ASCII | no | no | no |
Word 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 |
non‑ECMA Unicode | ASCII | Unicode | ASCII | ASCII | 5.3.4 Unicode 5.0.0 code page | ASCII | ASCII | ASCII | ASCII | ASCII | 3.0 Unicode 2.4 ASCII | Unicode | ECMA ASCII | ECMA extended egrep awk Unicode | no | no | no | ASCII | 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 |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | no | no | no | no | no |
Tcl word 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 |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | 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 |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | no | no | no | no | no |
Tcl 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 |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | 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 | ECMA extended egrep awk Unicode | no | no | no | ASCII | ASCII | no | no | no |
GNU 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 | ECMA extended egrep awk Unicode | no | no | no | ASCII | 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 | 8.34 ASCII | ASCII | 5.5.10 Unicode | XE7 ASCII | 3.0.3 ASCII | no | no | no | no | no | no | Unicode | Unicode | ASCII | ASCII | no | no | no | no | no |
POSIX 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 | 8.34 ASCII | ASCII | 5.5.10 Unicode | XE7 ASCII | 3.0.3 ASCII | no | no | no | no | no | no | Unicode | Unicode | ASCII | ASCII | no | 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 | YES | 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 |
---|