Easily work with any of these regex flavors today. Compose and analyze regex patterns with RegexBuddy's easy-to-grasp regex blocks and intuitive regex tree, which automatically adjusts itself to the particularities of the regex flavor you're working with. Safely test your regexes in RegexBuddy's sandbox, and get the same results your actual application would produce. Instantly convert a regular expression written for another regular expression flavor to the one you're using now. Let RegexBuddy take care of all the little details explained in the big comparison table below. Get your own copy of RegexBuddy now. |
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:
Easily work with any of these regex flavors today. Compose and analyze regex patterns with RegexBuddy's easy-to-grasp regex blocks and intuitive regex tree, which automatically adjusts itself to the particularities of the regex flavor you're working with. Safely test your regexes in RegexBuddy's sandbox, and get the same results your actual application would produce. Instantly convert a regular expression written for another regular expression flavor to the one you're using now. Let RegexBuddy take care of all the little details explained in the big comparison table below. Get your own copy of RegexBuddy now. |
Characters | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
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] | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
[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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
. (dot; any character except line break) | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES |
Anchors | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
^ (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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
\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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
| (alternation) | YES | YES | YES | YES | YES | YES | YES | YES | YES | no | YES | \| | YES | YES | YES |
Quantifiers | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
? (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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
(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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
(?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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
(?>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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
(?=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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
\G (start of match attempt) | YES | YES | YES | YES | YES | no | no | YES | no | no | no | no | no | no | no |
Conditionals | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
(?(?=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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
(?#comment) | YES | YES | no | YES | YES | no | YES | YES | YES | no | no | no | no | no | no |
Free-Spacing Syntax | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
\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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
\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 | 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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
(?<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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
\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 | |||||||||||||||
Feature | JGsoft | .NET | Java | Perl | PCRE | ECMA | Python | Ruby | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | XML | XPath |
[: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 |
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!
Page URL: http://www.Regular-Expressions.info/refflavors.html
Page last updated: 03 September 2012
Site last updated: 17 June 2013
Copyright © 2003-2013 Jan Goyvaerts. All rights reserved.
Books |
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 |
Regex Reference |
Basic Regex Syntax |
Advanced Regex Syntax |
Unicode-Specific Syntax |
Flavor-Specific Syntax |
Flavor Comparison |
Replacement Syntax |
More Information |
Introduction |
Quick Start |
Tutorial |
Tools and Languages |
Examples |
Books |
Reference |
Print PDF |
About This Site |
RSS Feed & Blog |
PowerGREP 4 |
PowerGREP is probably the most powerful regex-based text processing tool available today. A knowledge worker's Swiss army knife for searching through, extracting information from, and updating piles of files. |
Use regular expressions to search through large numbers of text and binary files. Quickly find the files you are looking for, or extract the information you need. Look through just a handful of files or folders, or scan entire drives and network shares. |
Search and replace using text, binary data or one or more regular expressions to automate repetitive editing tasks. Preview replacements before modifying files, and stay safe with flexible backup and undo options. |
Use regular expressions to rename files, copy files, or merge and split the contents of files. Work with plain text files, Unicode files, binary files, compressed files, and files in proprietary formats such as MS Office, OpenOffice, and PDF. Runs on Windows 2000, XP, Vista, 7, and 8. |
More information |
Download PowerGREP now |