This is a comparison of regular expression engines.
Libraries
- ^ boost_regex_formerly_regex
- ^ fuzzy_regexp_libraries
- ^ glib_gregex_version
- ^ icu4j
- ^ pcre_cpp
- ^ non_greedy
- ^ shy
- ^ backref
- ^ boost_regex_recursion
- ^ xpressive_recursion
- ^ frej_non_greedy
- ^ js_lookbehind_es2018
- ^ lua_non_greedy
- ^ python_regex_only2
- ^ var-length-via-es2018
- ^ directives_explanation
- ^ atomic_grouping_explanation
- ^ named_groups_explanation
- ^ balancing_groups_explanation
- ^ varlength_lookbehind_explanation
- ^ properties_limited
- ^ available_icu_55
- ^ available_java_7
- ^ The support and range of properties is dependent on implementation.
- ^ perl5_varlength_lookbehind
- ^ python_11_and_regex_only
- ^ python3_regex_only
- ^ regexplus-ims-style
- ^ regexplus-transpiled-to-native
- ^ regexplus-es2018-name-syntax
- ^ regexplus-x-flag
- ^ regexplus-v-flag
- ^ regexplus-v8-es2018-engine
- ^ unicode_native
- ^ partial_match_explanation
- ^ Java_Unicode
- ^ UCS2
- ^ 8.30
- ^ partial
- ^ Conversion
- ^ wxRegEx
Languages
| Language | Official website | Software license | Remarks |
|---|---|---|---|
| ActionScript 3 | ActionScript Technology Center | ||
| APL (APLX, Dyalog, GNU) | APL Wiki | ⎕SS (PCRE), ⎕R / ⎕S (PCRE), ⎕SS (PCRE2), respectively | |
| C++11 (C++) | C++ standards website | Since ISO14822:2011(e), similar to ECMAScript on default (Grammar Description) | |
| D | D | ||
| Elixir | elixir-lang.org | style="text-align: center;" {{free|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. |
| Erlang | erlang.org | style="text-align: center;" {{free|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. |
| Free Pascal (Object Pascal) | freepascal.org | Free Pascal 2.6+ ships with TRegExpr from Sorokin and two other regular expression libraries; See wiki.lazarus.freepascal.org/Regexpr. | |
| Go | go.dev | ||
| Haskell | Haskell.org | Omitted in the language report, and in GHC's Hierarchical Libraries | |
| Java | Java | REs are written as strings in source code: all backslashes must be doubled, harming readability. | |
| JavaScript (ECMAScript) | ECMA-262 | First-class citizens of the language with a special /.../mod syntax. Historically feature-limited, but improved since ES2018. Two major regex engines: V8's Irregexp (used in Chrome and Blink-based browsers, as well as Firefox, Node.js) and JavaScriptCore's YARR (in Safari and WebKit-based browsers). | |
| Julia | JuliaLang.org | REs are part of the language core library using PCRE built-in and an optional wrapper for (C code) ICU is available. | |
| Lua | Lua.org | Uses simplified, limited dialect; can be bound to more powerful library, like PCRE or an alternative parser like LPeg. | |
| Mathematica | Wolfram | ||
| .NET | MSDN | ||
| Nim | nim-lang.org | Standard library includes PCRE-based re and nre modules, as well as various alternatives (ex. strutils, pegs (Parsing Expression Grammar matching), strscans, parseutils, etc.). | |
| OCaml | Caml | As of 2010, 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). | |
| Perl | Perl.com | Full, central part of the language | |
| PHP | PHP.net | Has two implementations, with PCRE being the more efficient in speed, functions | |
| POSIX C (C) | POSIX.1 web publication | Supports POSIX BRE and ERE syntax | |
| Python | python.org | Python has two major implementations, the built in re and the regex library. | |
| Ruby | ruby-lang.org | 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. | |
| Rust | docs.rs | The primary regex crate does not allow look-around expressions. There is an Oniguruma binding called onig that does. | |
| SAP ABAP | SAP.com | ||
| Tcl | tcl.tk | Tcl library doubles as a regular expression library. | |
| Wolfram Language | Wolfram Research | ||
| XML Schema | W3C | ||
| XPath 3/XQuery | W3C |
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 [Note 6] | Shy groups [Note 7] | Recursion | Look-ahead | Look-behind | Backreferences [Note 8] | >9 indexable captures | |
|---|---|---|---|---|---|---|---|---|---|
| Boost.Regex | [Note 9] | ||||||||
| Boost.Xpressive | [Note 10] | ||||||||
| CL-PPCRE | |||||||||
| EmEditor | |||||||||
| FREJ | [Note 11] | [Note 11] | |||||||
| GLib/GRegex | |||||||||
| GNU grep | |||||||||
| Haskell | |||||||||
| RXP | |||||||||
| ICU Regex | |||||||||
| Java | |||||||||
| JavaScript (ECMAScript) | [Note 12] | ||||||||
| JGsoft | [3] | ||||||||
| Lua | [Note 13] | ||||||||
| .NET | |||||||||
| OCaml | |||||||||
| PCRE | |||||||||
| Perl | |||||||||
| PHP | |||||||||
| Python | [Note 14] | ||||||||
| Qt/QRegExp | |||||||||
| RE2 | |||||||||
| Regex+ | [Note 15] | ||||||||
| Ruby, Onigmo | |||||||||
| TRE | |||||||||
| Vim | |||||||||
| RGX | |||||||||
| Tcl | |||||||||
| TRegExpr | |||||||||
| XML Schema | |||||||||
| XPath 3/XQuery | |||||||||
| XRegExp | [Note 12] |
Part 2
| Directives [Note 16] | Conditionals | Atomic groups [Note 17] | Named capture [Note 18] | Comments | Embedded code | Unicode property support [4] | Balancing groups [Note 19] | Variable-length look-behinds [Note 20] | |
|---|---|---|---|---|---|---|---|---|---|
| Boost.Regex | [Note 21] | ||||||||
| Boost.Xpressive | |||||||||
| CL-PPCRE | [Note 21] | ||||||||
| EmEditor | |||||||||
| FREJ | |||||||||
| GLib/GRegex | [Note 21] | ||||||||
| GNU grep | |||||||||
| Haskell | |||||||||
| RXP | |||||||||
| ICU Regex | [Note 22] | ||||||||
| Java | [Note 23] | [Note 21] | |||||||
| JavaScript (ECMAScript) | [Note 21][Note 24][5] | ||||||||
| JGsoft | [Note 21] | ||||||||
| Lua | |||||||||
| .NET | [Note 21] | ||||||||
| OCaml | |||||||||
| PCRE | |||||||||
| Perl | [Note 25] | ||||||||
| PHP | |||||||||
| Python | [Note 26] | [Note 27] | [Note 14] | ||||||
| Qt/QRegExp | |||||||||
| RE2 | ? | [Note 21] | |||||||
| Regex+ | [Note 28] | [Note 29] | [Note 30] | [Note 31] | [Note 32] | [Note 33] | |||
| Ruby, Onigmo | [Note 21] | ||||||||
| Tcl | |||||||||
| TRE | |||||||||
| Vim | |||||||||
| RGX | |||||||||
| XML Schema | |||||||||
| XPath 3/XQuery | |||||||||
| XRegExp | Leading only |
API features
| Native UTF-16 support[Note 34] | Native UTF-8 support[Note 34] | Multi-line matching | Partial match[Note 35] | |
|---|---|---|---|---|
| Boost.Regex | ||||
| GLib/GRegex | ||||
| RXP | ||||
| ICU Regex | ||||
| Java | [Note 36] | [Note 36] | ||
| .NET | [Note 37] | |||
| PCRE | [Note 38] | |||
| Qt/QRegExp | [Note 39] | |||
| Qt/QRegularExpression | ||||
| Tcl | [Note 40] | |||
| TRE | ||||
| RGX | ||||
| wxWidgets::wxRegEx[Note 41] | ||||
| XRegExp |
See also
References
- ^ "Getting Started – Hyperscan 5.4.0 documentation"
- ^ "Regex - Regular Expressions in OCaml"
- ^ "Recursive Regex—Tutorial"
- ^ "UTS #18: Unicode Regular Expressions"
- ^ "ECMA-262, 9th edition, June 2018 ECMAScript® 2018 Language Specification". www.ecma-international.org. Retrieved 4 August 2020.
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