Comparison of regular expression engines
In-game article clicks load inline without leaving the challenge.
This is a comparison of regular expression engines.
Libraries
| Name | Official website | Programming language | Software license | Used by |
|---|---|---|---|---|
| Boost.Regex | C++ | Boost | Notepad++ >= 6.0.0, EmEditor | |
| Boost.Xpressive | C++ | Boost | ||
| DEELX | C++ | Proprietary | ||
| FREJ | Java | LGPL | ||
| GLib/GRegex | C | LGPL | ||
| GNU regex | C | LGPL | GNU libc, GNU programs | |
| GRETA | C++ | Proprietary | ||
| RTL, HLS | Proprietary | FPGA accelerated >100 Gbit/s regex engine for cybersecurity, financial, e-commerce industries. | ||
| Hyperscan | C, x86-specific assembly (SSSE3+) | 3-clause BSD | Rspamd | |
| ICU | C, C++ | Foundation (Apple and Swift open-source versions) | ||
| Irregexp | C++ | 3-clause BSD | Chrome, Firefox, Node.js | |
| Jakarta Regexp | Java | Apache | ||
| java.util.regex | Java | GNU GPLv2 with Classpath exception | jEdit | |
| JRegex | Java | BSD | ||
| MATLAB | Proprietary | |||
| Oniguruma | C | BSD | Atom, Take Command Console, Tera Term, TextMate, Sublime Text, SubEthaEdit, EmEditor, jq, Ruby | |
| Java port of Oniguruma | Java | MIT | JRuby, Nashorn (JavaScript engine) | |
| Pattwo | Stevesoft | Java (compatible with Java 1.0) | LGPL | |
| PCRE | C, C++ | BSD | Apache HTTP Server, Nginx, BBEdit, Edbrowse, Julia, HHVM, Notepad++ < 6.0.0, PHP, Delphi, R, Exim, SWI-Prolog, Elixir, Erlang | |
| Qt/QRegExp | 2013-12-12 at the Wayback Machine | C++ | , , | Kate, Kile |
| regex - Henry Spencer's regular expression libraries | C | BSD | ||
| RE2 | C++ | BSD | Go, Google Sheets, Gmail, G Suite | |
| Henry Spencer's Advanced Regular Expressions | C | BSD | ||
| RGX | C++ based component library | |||
| RXP | RTL | Proprietary | hardware-accelerated search acceleration using RegEx available for ASIC, FPGA and cloud. Enables massively parallel content processing at ultra-high speeds. | |
| SubReg | C | MIT | ||
| TPerlRegEx | Object Pascal | MPLv1.1 | ||
| TRE | C | BSD | musl | |
| TRegex | Java | UPL-1.0 | GraalVM | |
| TRegExpr | , , () | Object Pascal | Dual-license: freeware, or LGPL with static linking exception | Total Commander |
| Wolfram Language (Mathematica) | Wolfram Language | Proprietary | Mathematica, the Wolfram Development Platform | |
| XRegExp | JavaScript | MIT | ||
| YARR | C++ | 2-clause BSD | Safari, WebKit-based browsers, QML |
Languages
| Language | Official website | Software license | Remarks |
|---|---|---|---|
| ActionScript 3 | Free | ||
| APL (APLX, Dyalog, GNU) | Licensed by the respective implementation | ⎕SS (PCRE), ⎕R/⎕S (PCRE), ⎕SS (PCRE2), respectively | |
| C++11 (C++) | Licensed by the respective implementation | Since ISO14822:2011(e), similar to ECMAScript on default | |
| D | Boost Software License | ||
| Elixir | Apache 2.0 | Standard library includes PCRE-based . 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 | Apache 2.0 | Standard library includes PCRE-based . 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) | LGPL with static linking exception | Free Pascal 2.6+ ships with TRegExpr from Sorokin and two other regular expression libraries; See . | |
| Go | |||
| Haskell | BSD3 | Omitted in the language report, and in GHC's Hierarchical Libraries | |
| Java | GNU General Public License | REs are written as strings in source code: all backslashes must be doubled, harming readability. | |
| JavaScript (ECMAScript) | BSD3 | 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 | MIT License | REs are part of the language core library using PCRE built-in and an optional wrapper for (C code) ICU is available. | |
| Lua | MIT License | Uses simplified, limited dialect; can be bound to more powerful library, like PCRE or an alternative parser like LPeg. | |
| Mathematica | Proprietary | ||
| .NET | MIT License | ||
| Nim | MIT License | Standard library includes PCRE-based and modules, as well as various alternatives (ex. , (Parsing Expression Grammar matching), , , etc.). | |
| OCaml | LGPL | As of 2010[update], the standard module is generally regarded as deprecated; often recommended libraries are (with full support for PCRE) and (which is not as complete but claims better performance and provides frontends to popular syntaxes: PCRE, Perl, Posix, Emacs, shell globbing). | |
| Perl | Artistic License, or GNU General Public License | Full, central part of the language | |
| PHP | PHP License | Has two implementations, with PCRE being the more efficient in speed, functions | |
| POSIX C (C) | Licensed by the respective implementation | Supports syntax | |
| Python | Python Software Foundation License | Python has two major implementations, the built in and the library. | |
| Ruby | 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. | |
| Rust | MIT License | The primary regex crate does not allow look-around expressions. There is an Oniguruma binding called that does. | |
| SAP ABAP | Proprietary | ||
| Tcl | (BSD-style) | Tcl library doubles as a regular expression library. | |
| Wolfram Language | Proprietary: usable for free on a limited scale on the Wolfram Development platform | ||
| XML Schema | Licensed by the respective implementation | ||
| XPath 3/XQuery | Licensed by the respective implementation |
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 | Shy groups | Recursion | Look-ahead | Look-behind | Backreferences | >9 indexable captures | |
|---|---|---|---|---|---|---|---|---|---|
| Boost.Regex | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Boost.Xpressive | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| CL-PPCRE | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| EmEditor | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No |
| No | No | Some | Yes | No | No | No | Yes | Yes | |
| GLib/GRegex | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| GNU grep | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | —N/a |
| Haskell | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Yes | Yes | Yes | Yes | No | No | No | Yes | Yes | |
| ICU Regex | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Java | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| JavaScript (ECMAScript) | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| JGsoft | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Lua | Yes | Yes | Some | No | No | No | No | Yes | No |
| .NET | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| OCaml | Yes | Yes | No | No | No | No | No | Yes | No |
| PCRE | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Perl | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| PHP | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Python | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Qt/QRegExp | Yes | Yes | Yes | Yes | No | Yes | No | Yes | Yes |
| RE2 | Yes | Yes | Yes | Yes | No | No | No | No | Yes |
| Ruby, Onigmo | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| TRE | Yes | Yes | Yes | Yes | No | No | No | Yes | No |
| Vim | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No |
| RGX | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| Tcl | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
| TRegExpr | Yes | ? | Yes | ? | ? | ? | ? | ? | ? |
| XML Schema | Yes | Yes | No | —N/a | No | No | No | No | —N/a |
| XPath 3/XQuery | Yes | Yes | Yes | Yes | No | No | No | Yes | Yes |
| Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
Part 2
| Directives | Conditionals | Atomic groups | Named capture | Comments | Embedded code | Unicode property support | Balancing groups | Variable-length look-behinds | |
|---|---|---|---|---|---|---|---|---|---|
| Boost.Regex | Yes | Yes | Yes | Yes | Yes | No | Some | No | No |
| Boost.Xpressive | Yes | No | Yes | Yes | Yes | No | No | No | No |
| CL-PPCRE | Yes | Yes | Yes | Yes | Yes | Yes | Some | No | No |
| EmEditor | Yes | Yes | ? | ? | Yes | No | ? | No | No |
| No | No | Yes | Yes | Yes | No | ? | No | No | |
| GLib/GRegex | Yes | Yes | Yes | Yes | Yes | No | Some | No | No |
| GNU grep | Yes | Yes | ? | Yes | Yes | No | No | No | No |
| Haskell | ? | ? | ? | ? | ? | No | No | No | No |
| Yes | Yes | No | Yes | Yes | No | No | No | No | |
| ICU Regex | Yes | No | Yes | Yes | Yes | No | Yes | No | No |
| Java | Yes | No | Yes | Yes | Yes | No | Some | No | No |
| JavaScript (ECMAScript) | No | No | No | Yes | No | No | Some | No | Yes |
| JGsoft | Yes | Yes | Yes | Yes | Yes | No | Some | No | Yes |
| Lua | No | No | No | No | No | No | No | No | No |
| .NET | Yes | Yes | Yes | Yes | Yes | No | Some | Yes | Yes |
| OCaml | No | No | No | No | No | No | No | No | No |
| PCRE | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
| Perl | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
| PHP | Yes | Yes | Yes | Yes | Yes | No | No | No | No |
| Python | Yes | Yes | Yes | Yes | Yes | No | Yes | No | Yes |
| Qt/QRegExp | No | No | No | No | No | No | No | No | No |
| RE2 | Yes | No | ? | Yes | No | No | Some | No | No |
| Ruby, Onigmo | Yes | Yes | Yes | Yes | Yes | No | Some | No | No |
| Tcl | Yes | No | Yes | No | Yes | No | Yes | No | No |
| TRE | Yes | No | No | No | Yes | No | ? | No | No |
| Vim | Yes | No | Yes | No | No | No | No | No | Yes |
| RGX | Yes | Yes | Yes | Yes | Yes | No | Yes | No | No |
| XML Schema | No | No | No | No | No | No | Yes | No | No |
| XPath 3/XQuery | No | No | No | No | No | No | Yes | No | No |
| Leading only | No | No | Yes | Yes | No | Yes | No | Yes |
API features
| Native UTF-16 support | Native UTF-8 support | Multi-line matching | Partial match | |
|---|---|---|---|---|
| Boost.Regex | No | No | Yes | Yes |
| GLib/GRegex | Yes | Yes | Yes | Yes |
| Yes | Yes | No | Yes | |
| ICU Regex | Yes | No | Yes | ? |
| Java | Yes | Yes | Yes | Yes |
| .NET | No | Yes | Yes | ? |
| PCRE | Yes | Yes | Yes | Yes |
| Qt/QRegExp | Yes | No | No | Yes |
| Qt/QRegularExpression | Yes | Yes | Yes | Yes |
| Tcl | Yes | Yes | Yes | ? |
| TRE | Yes | Yes | Yes | ? |
| RGX | No | No | Yes | ? |
| wxWidgets:: | Yes | Yes | Yes | ? |
| Yes | Yes | Yes | No |
See also
- Regular expression § Implementations and running times
- Comparison of parser generators
External links
- – Detailed comparison of the most popular regular expression flavors
- – with support for Java, JavaScript, .Net, PHP, Python and Ruby
- – series of articles by Russ Cox, author of RE2