Regular Expression Flavor Comparison

Tutorial | Tools & Languages | Examples | Books & Reference |

Regular Expr. Cookbook | Teach Yourself Reg. Expr. | Mastering Regular Expr. | Java Regular Expressions | Oracle Regular Expr. | Regular Expr. Pocket Ref. | Regular Expr. Recipes | Regex Recipes for Windows |

Basic Regex Syntax | Advanced Regex Syntax | Unicode-Specific Syntax | Flavor-Specific Syntax | Flavor Comparison | Replacement Syntax |

RegexBuddy Get RegexBuddy to easily work with and convert between any of these regular expression flavors.

The table below compares which regular expression flavors support which regex features and syntax. The features are listed in the same order as in the regular expression reference.

The comparison shows regular expression flavors rather than particular applications or programming languages implementing one of those regular expression flavors.

Applications and languages implementing one of the above flavors are:

RegexBuddy Get RegexBuddy to easily work with and convert between any of these regular expression flavors.
Characters
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
Backslash escapes one metacharacter YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
\Q...\E escapes a string of metacharacters YES no Java 6 YES YES no no no no no no no no no no
\x00 through \xFF (ASCII character) YES YES YES YES YES YES YES YES YES no no no no no no
\n (LF), \r (CR) and \t (tab) YES YES YES YES YES YES YES YES YES no no no no YES YES
\f (form feed) and \v (vtab) YES YES YES YES YES YES YES YES YES no no no no no no
\a (bell) YES YES YES YES YES no YES YES YES no no no no no no
\e (escape) YES YES YES YES YES no no YES YES no no no no no no
\b (backspace) and \B (backslash) no no no no no no no no YES no no no no no no
\cA through \cZ (control character) YES YES YES YES YES YES no no YES no no no no no no
\ca through \cz (control character) YES YES no YES YES YES no no YES no no no no no no
Character Classes or Character Sets [abc]
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
[abc] character class YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
[^abc] negated character class YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
[a-z] character class range YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
Hyphen in [\d-z] is a literal YES YES YES YES YES no no no no no no no no no no
Hyphen in [a-\d] is a literal YES no no no YES no no no no no no no no no no
Backslash escapes one character class metacharacter YES YES YES YES YES YES YES YES YES no no no no YES YES
\Q...\E escapes a string of character class metacharacters YES no Java 6 YES YES no no no no no no no no no no
\d shorthand for digits YES YES ascii YES ascii ascii option ascii YES no no no no YES YES
\w shorthand for word characters YES YES ascii YES ascii ascii option ascii YES no no YES YES YES YES
\s shorthand for whitespace YES YES ascii YES ascii YES option ascii YES no no YES YES ascii ascii
\D, \W and \S shorthand negated character classes YES YES YES YES YES YES YES YES YES no no YES YES YES YES
[\b] backspace YES YES YES YES YES YES YES YES YES no no no no no no
Dot
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
. (dot; any character except line break) YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
Anchors
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
^ (start of string/line) YES YES YES YES YES YES YES YES YES YES YES YES YES no YES
$ (end of string/line) YES YES YES YES YES YES YES YES YES YES YES YES YES no YES
\A (start of string) YES YES YES YES YES no YES YES YES no no no no no no
\Z (end of string, before final line break) YES YES YES YES YES no no YES YES no no no no no no
\z (end of string) YES YES YES YES YES no \Z YES no no no no no no no
\` (start of string) no no no no no no no no no no no YES YES no no
\' (end of string) no no no no no no no no no no no YES YES no no
Word Boundaries
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
\b (at the beginning or end of a word) YES YES YES YES ascii ascii option ascii no no no YES YES no no
\B (NOT at the beginning or end of a word) YES YES YES YES ascii ascii option ascii no no no YES YES no no
\y (at the beginning or end of a word) YES no no no no no no no YES no no no no no no
\Y (NOT at the beginning or end of a word) YES no no no no no no no YES no no no no no no
\m (at the beginning of a word) YES no no no no no no no YES no no no no no no
\M (at the end of a word) YES no no no no no no no YES no no no no no no
\< (at the beginning of a word) no no no no no no no no no no no YES YES no no
\> (at the end of a word) no no no no no no no no no no no YES YES no no
Alternation
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
| (alternation) YES YES YES YES YES YES YES YES YES no YES \| YES YES YES
Quantifiers
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
? (0 or 1) YES YES YES YES YES YES YES YES YES no YES \? YES YES YES
* (0 or more) YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
+ (1 or more) YES YES YES YES YES YES YES YES YES no YES \+ YES YES YES
{n} (exactly n) YES YES YES YES YES YES YES YES YES \{n\} YES \{n\} YES YES YES
{n,m} (between n and m) YES YES YES YES YES YES YES YES YES \{n,m\} YES \{n,m\} YES YES YES
{n,} (n or more) YES YES YES YES YES YES YES YES YES \{n,\} YES \{n,\} YES YES YES
? after any of the above quantifiers to make it "lazy" YES YES YES YES YES YES YES YES YES no no no no no YES
Grouping and Backreferences
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
(regex) (numbered capturing group) YES YES YES YES YES YES YES YES YES \( \) YES \( \) YES YES YES
(?:regex) (non-capturing group) YES YES YES YES YES YES YES YES YES no no no no no no
\1 through \9 (backreferences) YES YES YES YES YES YES YES YES YES YES no YES YES no YES
\10 through \99 (backreferences) YES YES YES YES YES YES YES YES YES no n/a no no n/a YES
Forward references \1 through \9 YES YES YES YES YES no no YES no no n/a no no n/a no
Nested references \1 through \9 YES YES YES YES YES YES no YES no no n/a no no n/a no
Backreferences non-existent groups are an error YES YES YES YES YES no YES no YES YES n/a YES YES n/a YES
Backreferences to failed groups also fail YES YES YES YES YES no YES YES YES YES n/a YES YES n/a YES
Modifiers
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
(?i) (case insensitive) YES YES YES YES YES /i only YES YES YES no no no no no flag
(?s) (dot matches newlines) YES YES YES YES YES no YES (?m) no no no no no no flag
(?m) (^ and $ match at line breaks) YES YES YES YES YES /m only YES always on no no no no no no flag
(?x) (free-spacing mode) YES YES YES YES YES no YES YES YES no no no no no flag
(?n) (explicit capture) YES YES no no no no no no no no no no no no no
(?-ismxn) (turn off mode modifiers) YES YES YES YES YES no no YES no no no no no no no
(?ismxn:group) (mode modifiers local to group) YES YES YES YES YES no no YES no no no no no no no
Atomic Grouping and Possessive Quantifiers
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
(?>regex) (atomic group) YES YES YES YES YES no no YES no no no no no no no
?+, *+, ++ and {m,n}+ (possessive quantifiers) YES no YES no YES no no no no no no no no no no
Lookaround
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
(?=regex) (positive lookahead) YES YES YES YES YES YES YES YES YES no no no no no no
(?!regex) (negative lookahead) YES YES YES YES YES YES YES YES YES no no no no no no
(?<=text) (positive lookbehind) full regex full regex finite length fixed length fixed + alternation no fixed length no no no no no no no no
(?<!text) (negative lookbehind) full regex full regex finite length fixed length fixed + alternation no fixed length no no no no no no no no
Continuing from The Previous Match
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
\G (start of match attempt) YES YES YES YES YES no no YES no no no no no no no
Conditionals
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
(?(?=regex)then|else) (using any lookaround) YES YES no YES YES no no no no no no no no no no
(?(regex)then|else) no YES no no no no no no no no no no no no no
(?(1)then|else) YES YES no YES YES no YES no no no no no no no no
(?(group)then|else) YES YES no no YES no YES no no no no no no no no
Comments
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
(?#comment) YES YES no YES YES no YES YES YES no no no no no no
Free-Spacing Syntax
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
Free-spacing syntax supported YES YES YES YES YES no YES YES YES no no no no no YES
Character class is a single token YES YES no YES YES n/a YES YES YES n/a n/a n/a n/a n/a YES
# starts a comment YES YES YES YES YES n/a YES YES YES n/a n/a n/a n/a n/a no
Unicode Characters
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
\X (Unicode grapheme) YES no no YES option no no no no no no no no no no
\u0000 through \uFFFF (Unicode character) YES YES YES no no YES u"string" no YES no no no no no no
\x{0} through \x{FFFF} (Unicode character) YES no no YES option no no no no no no no no no no
Unicode Properties, Scripts and Blocks
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
\pL through \pC (Unicode properties) YES no YES YES option no no no no no no no no no no
\p{L} through \p{C} (Unicode properties) YES YES YES YES option no no no no no no no no YES YES
\p{Lu} through \p{Cn} (Unicode property) YES YES YES YES option no no no no no no no no YES YES
\p{L&} and \p{Letter&} (equivalent of [\p{Lu}\p{Ll}\p{Lt}] Unicode properties) YES no no YES option no no no no no no no no no no
\p{IsL} through \p{IsC} (Unicode properties) YES no YES YES no no no no no no no no no no no
\p{IsLu} through \p{IsCn} (Unicode property) YES no YES YES no no no no no no no no no no no
\p{Letter} through \p{Other} (Unicode properties) YES no no YES no no no no no no no no no no no
\p{Lowercase_Letter} through \p{Not_Assigned} (Unicode property) YES no no YES no no no no no no no no no no no
\p{IsLetter} through \p{IsOther} (Unicode properties) YES no no YES no no no no no no no no no no no
\p{IsLowercase_Letter} through \p{IsNot_Assigned} (Unicode property) YES no no YES no no no no no no no no no no no
\p{Arabic} through \p{Yi} (Unicode script) YES no no YES option no no no no no no no no no no
\p{IsArabic} through \p{IsYi} (Unicode script) YES no no YES no no no no no no no no no no no
\p{BasicLatin} through \p{Specials} (Unicode block) YES no no YES no no no no no no no no no no no
\p{InBasicLatin} through \p{InSpecials} (Unicode block) YES no YES YES no no no no no no no no no no no
\p{IsBasicLatin} through \p{IsSpecials} (Unicode block) YES YES no YES no no no no no no no no no YES YES
Part between {} in all of the above is case insensitive YES no no YES no no no no no no no no no no no
Spaces, hyphens and underscores allowed in all long names listed above (e.g. BasicLatin can be written as Basic-Latin or Basic_Latin or Basic Latin) YES no Java 5 YES no no no no no no no no no no no
\P (negated variants of all \p as listed above) YES YES YES YES option no no no no no no no no YES YES
\p{^...} (negated variants of all \p{...} as listed above) YES no no YES option no no no no no no no no no no
Named Capture and Backreferences
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
(?<name>regex) (.NET-style named capturing group) YES YES no no no no no no no no no no no no no
(?'name'regex) (.NET-style named capturing group) YES YES no no no no no no no no no no no no no
\k<name> (.NET-style named backreference) YES YES no no no no no no no no no no no no no
\k'name' (.NET-style named backreference) YES YES no no no no no no no no no no no no no
(?P<name>regex) (Python-style named capturing group YES no no no YES no YES no no no no no no no no
(?P=name) (Python-style named backreference) YES no no no YES no YES no no no no no no no no
multiple capturing groups can have the same name YES YES n/a n/a no n/a no n/a n/a n/a n/a n/a n/a n/a n/a
XML Character Classes
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
\i, \I, \c and \C shorthand XML name character classes no no no no no no no no no no no no no YES YES
[abc-[abc]] character class subtraction YES 2.0 no no no no no no no no no no no YES YES
POSIX Bracket Expressions
FeatureJGsoft.NETJavaPerlPCREECMAPythonRubyTcl AREPOSIX BREPOSIX EREGNU BREGNU EREXMLXPath
[:alpha:] POSIX character class YES no no YES ascii no no YES YES YES YES YES YES no no
\p{Alpha} POSIX character class YES no ascii no no no no no no no no no no no no
\p{IsAlpha} POSIX character class YES no no YES no no no no no no no no no no no
[.span-ll.] POSIX collation sequence no no no no no no no no YES YES YES YES YES no no
[=x=] POSIX character equivalence no no no no no no no no YES YES YES YES YES no no
RegexBuddy Get RegexBuddy to easily work with and convert between any of these regular expression flavors.

Tutorial | Tools & Languages | Examples | Books & Reference |

Regular Expr. Cookbook | Teach Yourself Reg. Expr. | Mastering Regular Expr. | Java Regular Expressions | Oracle Regular Expr. | Regular Expr. Pocket Ref. | Regular Expr. Recipes | Regex Recipes for Windows |

Basic Regex Syntax | Advanced Regex Syntax | Unicode-Specific Syntax | Flavor-Specific Syntax | Flavor Comparison | Replacement Syntax |