Comparison of regular expression engines
This is a comparison of regular expression engines.
Libraries
<templatestyles src="Reflist/styles.css" />
Cite error: <ref> tag with name "boost_regex_formerly_regex" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "glib_gregex_version" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "pcre_cpp" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "fuzzy_regexp_libraries" defined in <references> is not used in prior text.
<ref> tag with name "icu4j" defined in <references> is not used in prior text.Script error: No such module "Check for unknown parameters".
Languages
| Language | Official website | Software license | Remarks |
|---|---|---|---|
| Template:Rh | ActionScript 3 | ActionScript Technology Center | Free | |
| Template:Rh | APL (APLX, Dyalog, GNU) | APL Wiki | Licensed by the respective implementation | ⎕SS (PCRE), ⎕R/⎕S (PCRE), ⎕SS (PCRE2), respectively
|
| Template:Rh | C++11 (C++) | C++ standards website | Licensed by the respective implementation | Since ISO14822:2011(e), similar to ECMAScript on default (Grammar Description) |
| Template:Rh | D | D | Boost Software LicenseTemplate:R | |
| Template:Rh | Elixir | elixir-lang.org | Apache 2.0 | Standard library includes PCRE-based Regex module. The matching algorithms of the library are based on the PCRE library, but not all of the PCRE library is interfaced and some parts of the library go beyond what PCRE offers. Currently PCRE version 8.40 (release date 2017-01-11) is used. |
| Template:Rh | Erlang | erlang.org | Apache 2.0 | Standard library includes PCRE-based re module. The matching algorithms of the library are based on the PCRE library, but not all of the PCRE library is interfaced and some parts of the library go beyond what PCRE offers. Currently PCRE version 8.40 (release date 2017-01-11) is used. |
| Template:Rh | Free Pascal (Object Pascal) | freepascal.org | LGPL with static linking exception | Free Pascal 2.6+ ships with TRegExpr from Sorokin and two other regular expression libraries; See wiki.lazarus.freepascal.org/Regexpr. |
| Template:Rh | Go | go.dev | BSD-style | |
| Template:Rh | Haskell | Haskell.org | BSD3 | Omitted in the language report, and in GHC's Hierarchical Libraries |
| Template:Rh | Java | Java | GNU General Public License | REs are written as strings in source code: all backslashes must be doubled, harming readability. |
| Template:Rh | JavaScript (ECMAScript) | ECMA-262 | BSD3 | Limited but REs are first-class citizens of the language with a specific /.../mod syntax.
|
| Template:Rh | Julia | JuliaLang.org | MIT License | REs are part of the language core library using PCRE built-in and an optional wrapper for (C code) ICU is available. |
| Template:Rh | Lua | Lua.org | MIT License | Uses simplified, limited dialect; can be bound to more powerful library, like PCRE or an alternative parser like LPeg. |
| Template:Rh | Mathematica | Wolfram | Proprietary | |
| Template:Rh | .NET | MSDN | MIT LicenseTemplate:RTemplate:R | |
| Template:Rh | Nim | nim-lang.org | MIT License | Standard library includes PCRE-based re and nre modules, as well as various alternatives (ex. strutils, pegs (Parsing Expression Grammar matching), strscans, parseutils, etc.). |
| Template:Rh | OCaml | Caml | LGPL | since 2010[update]Template:Dated maintenance category (articles)Script error: No such module "Check for unknown parameters"., the standard module is generally regarded as deprecated;[2] often recommended libraries are pcre (with full support for PCRE) and re (which is not as complete but claims better performance and provides frontends to popular syntaxes: PCRE, Perl, Posix, Emacs, shell globbing). |
| Template:Rh | Perl | Perl.com | Artistic License, or GNU General Public License | Full, central part of the language |
| Template:Rh | PHP | PHP.net | PHP License | Has two implementations, with PCRE being the more efficient in speed, functions |
| Template:Rh | POSIX C (C) | POSIX.1 web publication | Licensed by the respective implementation | Supports POSIX BRE and ERE syntax |
| Template:Rh | Python | python.org | Python Software Foundation License | Python has two major implementations, the built in re and the regex library. |
| Template:Rh | Ruby | ruby-lang.org | GNU Library General Public License | Ruby 1.8, Ruby 1.9, and Ruby 2.0 and later versions use different engines; Ruby 1.9 integrates Oniguruma, Ruby 2.0 and later integrate Onigmo, a fork from Oniguruma. |
| Template:Rh | Rust | docs.rs | MIT License | The primary regex crate does not allow look-around expressions. There is an Oniguruma binding called onig that does. |
| Template:Rh | SAP ABAP | SAP.com | Proprietary | |
| Template:Rh | Tcl | tcl.tk | Tcl/Tk License (BSD-style) |
Tcl library doubles as a regular expression library. |
| Template:Rh | Wolfram Language | Wolfram Research | Proprietary: usable for free on a limited scale on the Wolfram Development platform | |
| Template:Rh | XML Schema | W3C | Licensed by the respective implementation | |
| Template:Rh | XPath 3/XQuery | W3C | Licensed by the respective implementation |
<templatestyles src="Reflist/styles.css" />
Cite error: <ref> tag with name "boost_mars" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "dotnet_regex_license" defined in <references> is not used in prior text.
<ref> tag with name "dotnet_license" defined in <references> is not used in prior text.Script error: No such module "Check for unknown parameters".
Language features
NOTE: An application using a library for regular expression support does not necessarily support the full set of features of the library, e.g., GNU grep uses PCRE, but supports no lookahead, though PCRE does.
Part 1
| "+" quantifier | Negated character classes | Non-greedy quantifiers Template:R |
Shy groups Template:R |
Recursion | Look-ahead | Look-behind | Backreferences Template:R |
>9 indexable captures | |
|---|---|---|---|---|---|---|---|---|---|
| Template:Rh | Boost.Regex | Yes | Yes | Yes | Yes | YesTemplate:R | Yes | Yes | Yes | Yes |
| Template:Rh | Boost.Xpressive | Yes | Yes | Yes | Yes | YesTemplate:R | Yes | Yes | Yes | Yes |
| Template:Rh | CL-PPCRE | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Template:Rh | EmEditor | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No |
| Template:Rh | FREJ | NoTemplate:R | No | SomeTemplate:R | Yes | No | No | No | Yes | Yes |
| Template:Rh | GLib/GRegex | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Template:Rh | GNU grep | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | — |
| Template:Rh | Haskell | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Template:Rh |RXP | Yes | Yes | Yes | Yes | No | No | No | Yes | Yes |
| Template:Rh | ICU Regex | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Template:Rh | Java | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Template:Rh | JavaScript (ECMAScript) | Yes | Yes | Yes | Yes | No | Yes | YesTemplate:R | Yes | Yes |
| Template:Rh | JGsoft | Yes | Yes | Yes | Yes | Yes[3] | Yes | Yes | Yes | Yes |
| Template:Rh | Lua | Yes | Yes | SomeTemplate:R | No | No | No | No | Yes | No |
| Template:Rh | .NET | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Template:Rh | OCaml | Yes | Yes | No | No | No | No | No | Yes | No |
| Template:Rh | PCRE | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Template:Rh | Perl | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Template:Rh | PHP | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Template:Rh | Python | Yes | Yes | Yes | Yes | YesTemplate:R | Yes | Yes | Yes | Yes |
| Template:Rh | Qt/QRegExp | Yes | Yes | Yes | Yes | No | Yes | No | Yes | Yes |
| Template:Rh | RE2 | Yes | Yes | Yes | Yes | No | No | No | No | Yes |
| Template:Rh | Ruby, Onigmo | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Template:Rh | TRE | Yes | Yes | Yes | Yes | No | No | No | Yes | No |
| Template:Rh | Vim | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No |
| Template:Rh | RGX | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Template:Rh | Tcl | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Template:Rh | TRegExpr | Yes | ? | Yes | ? | ? | ? | ? | ? | ? |
| Template:Rh | XML Schema | Yes | Yes | No | — | No | No | No | No | — |
| Template:Rh | XPath 3/XQuery | Yes | Yes | Yes | Yes | No | No | No | Yes | Yes |
| Template:Rh | XRegExp | Yes | Yes | Yes | Yes | No | Yes | YesTemplate:R | Yes | Yes |
<templatestyles src="Reflist/styles.css" />
Cite error: <ref> tag with name "non_greedy" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "shy" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "backref" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "xpressive_recursion" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "boost_regex_recursion" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "frej_non_greedy" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "lua_non_greedy" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "python_regex_only2" defined in <references> is not used in prior text.
<ref> tag with name "js_lookbehind_es2018" defined in <references> is not used in prior text.Script error: No such module "Check for unknown parameters".
Part 2
| Directives Template:R |
Conditionals | Atomic groups Template:R |
Named capture Template:R |
Comments | Embedded code | Unicode property support [4] | Balancing groups Template:R |
Variable-length look-behinds Template:R | |
|---|---|---|---|---|---|---|---|---|---|
| Template:Rh | Boost.Regex | Yes | Yes | Yes | Yes | Yes | No | SomeTemplate:R | No | No |
| Template:Rh | Boost.Xpressive | Yes | No | Yes | Yes | Yes | No | No | No | No |
| Template:Rh | CL-PPCRE | Yes | Yes | Yes | Yes | Yes | Yes | SomeTemplate:R | No | No |
| Template:Rh | EmEditor | Yes | Yes | ? | ? | Yes | No | ? | No | No |
| Template:Rh | FREJ | No | No | Yes | Yes | Yes | No | ? | No | No |
| Template:Rh | GLib/GRegex | Yes | Yes | Yes | Yes | Yes | No | SomeTemplate:R | No | No |
| Template:Rh | GNU grep | Yes | Yes | ? | Yes | Yes | No | No | No | No |
| Template:Rh | Haskell | ? | ? | ? | ? | ? | No | No | No | No |
| Template:Rh |RXP | Yes | Yes | No | Yes | Yes | No | No | No | No |
| Template:Rh | ICU Regex | Yes | No | Yes | YesTemplate:R | Yes | No | Yes | No | No |
| Template:Rh | Java | Yes | No | Yes | YesTemplate:R | Yes | No | SomeTemplate:R | No | No |
| Template:Rh | JavaScript (ECMAScript) | No | No | No | Yes | No | No | SomeTemplate:R[Note 1][5] | No | Yes |
| Template:Rh | JGsoft | Yes | Yes | Yes | Yes | Yes | No | SomeTemplate:R | No | Yes |
| Template:Rh | Lua | No | No | No | No | No | No | No | No | No |
| Template:Rh | .NET | Yes | Yes | Yes | Yes | Yes | No | SomeTemplate:R | Yes | Yes |
| Template:Rh | OCaml | No | No | No | No | No | No | No | No | No |
| Template:Rh | PCRE | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
| Template:Rh | Perl | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | NoTemplate:R |
| Template:Rh | PHP | Yes | Yes | Yes | Yes | Yes | No | No | No | No |
| Template:Rh | Python | Yes | Yes | YesTemplate:R | Yes | Yes | No | YesTemplate:R | No | YesTemplate:R |
| Template:Rh | Qt/QRegExp | No | No | No | No | No | No | No | No | No |
| Template:Rh | RE2 | Yes | No | ? | Yes | No | No | SomeTemplate:R | No | No |
| Template:Rh | Ruby, Onigmo | Yes | Yes | Yes | Yes | Yes | No | SomeTemplate:R | No | No |
| Template:Rh | Tcl | Yes | No | Yes | No | Yes | No | Yes | No | No |
| Template:Rh | TRE | Yes | No | No | No | Yes | No | ? | No | No |
| Template:Rh | Vim | Yes | No | Yes | No | No | No | No | No | Yes |
| Template:Rh | RGX | Yes | Yes | Yes | Yes | Yes | No | Yes | No | No |
| Template:Rh | XML Schema | No | No | No | No | No | No | Yes | No | No |
| Template:Rh | XPath 3/XQuery | No | No | No | No | No | No | Yes | No | No |
| Template:Rh | XRegExp | Leading only | No | No | Yes | Yes | No | Yes | No | Yes |
<templatestyles src="Reflist/styles.css" />
- ↑ The support and range of properties is dependent on implementation.
Cite error: <ref> tag with name "directives_explanation" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "atomic_grouping_explanation" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "named_groups_explanation" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "available_java_7" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "available_icu_55" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "properties_limited" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "balancing_groups_explanation" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "varlength_lookbehind_explanation" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "perl5_varlength_lookbehind" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "python_regex_only2" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "python_11_and_regex_only" defined in <references> is not used in prior text.
<ref> tag with name "python3_regex_only" defined in <references> is not used in prior text.Script error: No such module "Check for unknown parameters".
API features
| Native UTF-16 supportTemplate:R | Native UTF-8 supportTemplate:R | Multi-line matching | Partial matchTemplate:R | |
|---|---|---|---|---|
| Template:Rh | Boost.Regex | No | No | Yes | Yes |
| Template:Rh | GLib/GRegex | Yes | Yes | Yes | Yes |
| Template:Rh | RXP | Yes | Yes | No | Yes |
| Template:Rh | ICU Regex | Yes | No | Yes | ? |
| Template:Rh | Java | YesTemplate:R | YesTemplate:R | Yes | Yes |
| Template:Rh | .NET | NoTemplate:R | Yes | Yes | ? |
| Template:Rh | PCRE | YesTemplate:R | Yes | Yes | Yes |
| Template:Rh | Qt/QRegExp | Yes | No | No | YesTemplate:R |
| Template:Rh | Qt/QRegularExpression | Yes | Yes | Yes | Yes |
| Template:Rh | Tcl | Yes | YesTemplate:R | Yes | ? |
| Template:Rh | TRE | Yes | Yes | Yes | ? |
| Template:Rh | RGX | No | No | Yes | ? |
| Template:Rh | wxWidgets::wxRegExTemplate:R | Yes | Yes | Yes | ? |
| Template:Rh | XRegExp | Yes | Yes | Yes | No |
<templatestyles src="Reflist/styles.css" />
Cite error: <ref> tag with name "UCS2" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "unicode_native" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "Java_Unicode" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "8.30" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "partial" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "Conversion" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "partial_match_explanation" defined in <references> is not used in prior text.
<ref> tag with name "wxRegEx" defined in <references> is not used in prior text.Script error: No such module "Check for unknown parameters".
See also
References
<templatestyles src="Reflist/styles.css" />
Script error: No such module "Check for unknown parameters".
External links
- Regular Expression Flavor Comparison – Detailed comparison of the most popular regular expression flavors
- Regexp Syntax Summary
- Online Regular Expression Testing – with support for Java, JavaScript, .Net, PHP, Python and Ruby
- Implementing Regular Expressions – series of articles by Russ Cox, author of RE2
- Regular Expression Engines