请输入您要查询的百科知识:

 

词条 Comparison of regular expression engines
释义

  1. Libraries

  2. Languages

  3. Language features

     Part 1  Part 2 

  4. API features

  5. See also

  6. References

  7. External links

{{multiple issues|{{cleanup|reason=redlinks etc for nonnotable programs|date=January 2013}}{{external links|date=January 2013}}
}}

This is a comparison of regular expression engines.

Libraries

List of regular expression libraries
Name Official website Programming language Software license Used by
Boost.Regex{{R|group=Note|boost_regex_formerly_regex Boost C++ Libraries C++Boost}} Notepad++ >= 6.0.0, EmEditor
Boost{{Not a typo|.Xpressive Boost C++ Libraries C++Boost}}  
CL-PPCRE Edi Weitz Common LispBSD}}  
cppre [https://archive.is/20081203133158/http://jeff.bleugris.com/journal/projects/ Jeff Stuart] C++GPL}}  
DEELX [https://web.archive.org/web/20081201072631/http://www.regexlab.com/en/deelx/ RegExLab] C++ {{free}} personal and commercial use  
FREJ{{R|group=Note|fuzzy_regexp_libraries Fuzzy Regular Expressions for Java JavaLGPL}}  
GLib/GRegex{{R|group=Note|glib_gregex_version [https://developer.gnome.org/glib/unstable/glib-Perl-compatible-regular-expressions.html GLib reference manual] CLGPL}}  
GRETA Microsoft Research C++ {{dunno}}  
Helios RXPF Titan IC RTL {{Proprietary}} hardware accelerated regex engine for cybersecurity OEMs
Hyperscan[https://www.hyperscan.io/ Intel] C, x86-specific assembly (SSSE3+[1])3-clause BSD}} [https://rspamd.com Rspamd]
ICU International Components for Unicodegroup=Note|icu4j}}[https://github.com/unicode-org/icu/blob/master/icu4c/LICENSE ICU]}}Foundation (Apple and Swift open-source versions)
Jakarta/Regexp The Apache Jakarta Project JavaApache}}  
java.util.regex Java's User manual JavaGNU GPLv2 with Classpath exception}} jEdit
JRegex JRegex JavaBSD}}  
MATLAB [https://www.mathworks.com/help/matlab/ref/regexp.html Regular Expressions][https://www.mathworks.com/help/matlab/language-fundamentals.html MATLAB Language]MATLAB, The Language of Technical Computing  
Oniguruma[https://github.com/kkos/oniguruma Kosako] CBSD}} Atom, Take Command Console, Tera Term, TextMate, Sublime Text, SubEthaEdit, EmEditor and jq
Pattwo Stevesoft Java (compatible with Java 1.0)LGPL}}  
PCRE pcre.orggroup=Note|pcre_cpp}}BSD}} Apache HTTP Server, Nginx, Julia, HHVM, Notepad++ < 6.0.0, PHP
Qt/QRegExp Digia C++Qt GNU GPL v. 3.0,

Qt GNU LGPL v. 2.1,

Qt Commercial}}

Kate, Kile
regex - Henry Spencer's regular expression libraries ArgList CBSD}}  
RE2 [https://github.com/google/re2 RE2] C++BSD}}  
Henry Spencer's Advanced Regular Expressions [https://web.archive.org/web/20131122023923/http://www2.tcl.tk/461 Tcl] CBSD}}  
RGX [https://web.archive.org/web/20110715032327/https://www.p6r.com/software/rgx.html RGX ] C++ based component library[https://www.p6r.com/p6r-software-library-license-1-1.html P6R]}}  
SubReg [https://github.com/mattbucknall/subreg Matt Bucknall] CMIT}}  
TPerlRegEx TPerlRegEx VCL Component Object PascalMPLv1.1}}  
TRE{{R|group=Note|fuzzy_regexp_libraries Ville Laurikari CBSD}}  
TRegExpr RegExp Studio Object PascalDual-license: freeware, or LGPL with static linking exception}} Total Commander
XRegExp XRegExp JavaScriptMIT}}  
Wolfram Language (Mathematica) Wolfram Language Documentation Center Wolfram Language Mathematica, the Wolfram Development Platform
1. ^https://intel.github.io/hyperscan/dev-reference/getting_started.html#requirements
2. ^[https://stackoverflow.com/questions/3221067#comment3323649_3221067]
3. ^http://www.digitalmars.com/d/2.0/phobos/std_regex.html
4. ^https://github.com/dotnet/corefx/blob/7116584186f8f3a886616aaf8cb5d4a982c60e27/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs#L2
5. ^https://github.com/dotnet/corefx#license
6. ^Non-greedy quantifiers match as few characters as possible, instead of the default as many. Note that many older, pre-POSIX engines were non-greedy and didn't have greedy quantifiers at all.
7. ^Shy groups, also called non-capturing groups cannot be referred to with backreferences; non-capturing groups are used to speed up matching where the group's content does not need to be accessed later.
8. ^Backreferences enable referring to previously matched groups in later parts of the regex and/or replacement string (where applicable). For instance, ([ab]+)\\1 matches "abab" but not "abaab".
9. ^http://www.boost.org/doc/libs/1_47_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.grammars_and_nested_matches.embedding_a_regex_by_reference
10. ^http://www.boost.org/doc/libs/1_47_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.recursive_expressions
11. ^FREJ have no repetitive quantifiers, but have "optional" element which behaves similar to simple "?" quantifier.
12. ^Regular Expressions as used in R
13. ^Lua's only non-greedy quantifier is -, which is a non-greedy version of *. It does not have non-greedy versions of + or ?; in the former case, the non-greedy effect can be achieved by repeating the token followed by -, but in the latter case, there is no equivalent.
14. ^Supported by the optional [https://pypi.python.org/pypi/regex regex] library only.
15. ^https://www.unicode.org/reports/tr18/
16. ^Also known as Flags modifiers, Modes modifiers or Option letters. Example pattern: "(?i:test)".
17. ^Also called Independent sub-expressions
18. ^Similar to back references but with names instead of indices
19. ^Available as of JDK7
20. ^Available as of ICU55
21. ^Unicode property support may be incomplete (products are continuously updated!). All will be incomplete when a new Unicode revision is released until they are updated to comply.
22. ^Special feature allowing to match balanced constructs without recursion
23. ^Refers to the possibility of including quantifiers in look-behinds, thus making their length unpredictable
24. ^Supported by the optional [https://pypi.python.org/pypi/regex regex] library only.
25. ^May only be available in the regex library when used with Python versions after 3.3
26. ^Implementation uses original UCS-2 support/features, so it only recognizes 64K chars total (vs UTF-16's 1,112,064 characters). A Microsoft developer-representative answered a bug report on this as "will not fix" in 2010. .
27. ^Means the format can be used internally without explicit conversion.
28. ^Supports Unicode 4.0 standard from 2003; latest plans for JDK7 include Unicode 6.0 (2011) support. 
29. ^Since version 8.30
30. ^Tcl includes facilities to convert to and from UTF-8.
31. ^Partial match of the whole regular expression. For example the pattern ".*END$" will match any string partially, but only strings ending with END fully. 
32. ^wxRegEx uses any system supplied POSIX library or if not available and for Unicode mode uses Henry Spencer's library.

Languages

List of languages and frameworks including regular expression support
Language Official website Software license Remarks
ActionScript 3 [https://www.adobe.com/devnet/actionscript.html ActionScript Technology Center] {{free}}
C++11 (C++) C++ standards website {{dunno}}Since ISO14822:2011(e)
D DBoost Software License{{R|group=Note|boost_mars}}}}
Go Golang.orgBSD-style}}
Haskell Haskell.orgBSD3}}Omitted in the language report, and in GHC's Hierarchical Libraries
Java JavaGNU General Public License}}REs are written as strings in source code: all backslashes must be doubled, harming readability.
JavaScript (ECMAScript) ECMA-262BSD3}}Limited but REs are first-class citizens of the language with a specific /.../mod syntax.
Julia JuliaLang.orgMIT License}}REs are part of the language core library using PCRE built-in and an optional wrapper for (C code) ICU is available.
Lua Lua.orgMIT License}}Uses simplified, limited dialect; can be bound to more powerful library, like PCRE or an alternative parser like LPeg.
Mathematica Wolfram Proprietary
.NET MSDNMIT License{{R|group=Note|dotnet_regex_license}}{{R|group=Note|dotnet_license}}}}
Nim [https://nim-lang.org nim-lang.org]MIT License}}Standard library includes PCRE-based [https://nim-lang.org/docs/re.html re] and [https://nim-lang.org/docs/nre.html nre] modules, as well as various alternatives (ex. [https://nim-lang.org/docs/strutils.html strutils], [https://nim-lang.org/docs/pegs.html pegs] (Parsing Expression Grammar matching), [https://nim-lang.org/docs/strscans.html strscans], [https://nim-lang.org/docs/parseutils.html parseutils], etc.).
Free Pascal (Object Pascal) www.freepascal.orgLGPL 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.
OCaml CamlLGPL}}{{As of|2010}}, the standard module is generally regarded as deprecated;[2] often recommended libraries are [https://github.com/mmottl/pcre-ocaml pcre] (with full support for PCRE) and [https://github.com/ocaml/ocaml-re re] (which is not as complete but claims better performance and provides frontends to popular syntaxes: PCRE, Perl, Posix, Emacs, shell globbing).
Perl Perl.comArtistic License, or GNU General Public License}}Full, central part of the language
PHP PHP.netPHP License}}Has two implementations, with PCRE being the more efficient in speed, functions
POSIX C (C) libc/regex from BSD BSDAccording to regex(3), available from at least 4.4BSD (if not earlier)
Python [https://docs.python.org/2/library/re.html python.org]Python Software Foundation License}}Python has two major implementations, the built in [https://docs.python.org/3/library/re.html re] and the [https://pypi.python.org/pypi/regex regex] library.
Ruby ruby-doc.orgGNU Library General Public License}}Ruby 1.8 and 1.9 use different engines; 1.9 integrates Oniguruma.
SAP ABAP SAP.com {{proprietary}}
Tcl tcl.tkTcl/Tk License
(BSD-style)}}
Tcl library doubles as a regular expression library.
Wolfram Language Wolfram Research Proprietary; usable for free on a limited scale on the Wolfram Development platform.{{Clear}}
{{Reflist|group=Note|refs=[3][4][5]
}}

Language features

NOTE: An application using a library for regular expression support does not necessarily offer the full set of features of the library, e.g. GNU grep which uses PCRE does not offer lookahead support, though PCRE does.

Part 1

Language feature comparison (part 1)
"+" quantifier Negated character classesgroup=Note|non_greedygroup=Note|shy Recursion Look-ahead Look-behindgroup=Note|backref >9 indexable captures
Boost.Regex {{yes}} {{yes}} {{yes}} {{yes}}group=Note|boost_regex_recursion}} {{yes}} {{yes}} {{yes}} {{yes}}
Boost.Xpressive {{yes}} {{yes}} {{yes}} {{yes}}group=Note|xpressive_recursion}} {{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}}
FREJgroup=Note|frej_non_greedy}} {{No}}group=Note|frej_non_greedy}} {{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}} {{dunno}}
Haskell {{yes}} {{yes}} {{yes}} {{yes}} {{No}} {{yes}} {{yes}} {{yes}} {{yes}}
Helios RXPF {{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}} {{No}} {{yes}} {{yes}}
JGsoft {{yes}} {{yes}} {{yes}} {{yes}} {{No}} {{yes}} {{yes}} {{yes}} {{yes}}
Lua {{yes}} {{yes}}group=Note|lua_non_greedy}} {{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}}
OmniOutliner 3.6.2 {{yes}} {{yes}} {{yes}} {{No}} {{No}} {{No}} {{No}} {{dunno}} {{dunno}}
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}}group=Note|python_regex_only2}} {{yes}} {{yes}} {{yes}} {{yes}}
Qt/QRegExp {{yes}} {{yes}} {{yes}} {{yes}} {{No}} {{yes}} {{No}} {{yes}} {{yes}}
R{{R|group=Note|r_regex}} {{yes}} {{yes}} {{yes}} {{yes}} {{No}} {{yes}} {{yes}} {{yes}} {{yes}}
RE2 {{yes}} {{yes}} {{yes}} {{yes}} {{No}} {{No}} {{No}} {{No}} {{yes}}
Ruby {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{yes}}
TRE {{yes}} {{yes}} {{yes}} {{yes}} {{No}} {{No}} {{No}} {{yes}} {{No}}
Vim {{Latest preview release/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}} {{dunno}} {{yes}} {{dunno}} {{dunno}} {{dunno}} {{dunno}} {{dunno}} {{dunno}}
XRegExp {{yes}} {{yes}} {{yes}} {{yes}} {{no}} {{yes}} {{no}} {{yes}} {{yes}}
{{Reflist|group=Note|refs=[6][7][8][9][10][11][12][13][14]
}}

Part 2

Language feature comparison (part 2)
group=Note|directives_explanation Conditionalsgroup=Note|atomic_grouping_explanationgroup=Note|named_groups_explanation Comments Embedded code Unicode property support [15]group=Note|balancing_groups_explanationgroup=Note|varlength_lookbehind_explanation
Boost.Regex {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{No}}group=Note|properties_limited}} {{No}} {{No}}
Boost.Xpressive {{yes}} {{No}} {{yes}} {{yes}} {{yes}} {{No}} {{No}} {{No}} {{No}}
CL-PPCRE {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{yes}}group=Note|properties_limited}} {{No}} {{No}}
EmEditor {{yes}} {{yes}} {{dunno}} {{dunno}} {{yes}} {{No}} {{dunno}} {{No}} {{No}}
FREJ {{No}} {{No}} {{yes}} {{yes}} {{yes}} {{No}} {{dunno}} {{No}} {{No}}
GLib/GRegex {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{No}}group=Note|properties_limited}} {{No}} {{No}}
GNU grep {{yes}} {{yes}} {{dunno}} {{yes}} {{yes}} {{No}} {{No}} {{No}} {{No}}
Haskell {{dunno}} {{dunno}} {{dunno}} {{dunno}} {{dunno}} {{No}} {{No}} {{No}} {{No}}
Helios RXPF {{yes}} {{yes}} {{No}} {{yes}} {{yes}} {{No}} {{No}} {{No}} {{No}}
ICU Regex {{yes}} {{no}} {{yes}}group=Note|available_icu_55}} {{yes}} {{No}} {{yes}} {{No}} {{No}}
Java {{yes}} {{no}} {{yes}}group=Note|available_java_7}} {{yes}} {{No}}group=Note|properties_limited}} {{No}} {{No}}
JavaScript (ECMAScript) {{No}} {{No}} {{No}} {{No}} {{No}} {{No}} {{No}} {{No}} {{No}}
JGsoft {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{No}}group=Note|properties_limited}} {{No}} {{Yes}}
Lua {{no}} {{no}} {{no}} {{no}} {{no}} {{no}} {{no}} {{No}} {{No}}
.NET {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{No}}group=Note|properties_limited}} {{yes}} {{yes}}
OCaml {{no}} {{no}} {{no}} {{no}} {{no}} {{no}} {{no}} {{No}} {{No}}
OmniOutliner 3.6.2 {{dunno}} {{dunno}} {{dunno}} {{dunno}} {{No}} {{No}} {{dunno}} {{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}}group=Note|python_regex_only2}} {{yes}} {{yes}} {{No}}group=Note|python3_regex_only}} {{No}}group=Note|python_regex_only2}}
Qt/QRegExp {{No}} {{No}} {{No}} {{No}} {{No}} {{No}} {{No}} {{No}} {{No}}
RE2 {{yes}} {{No}} ? {{yes}} {{No}} {{No}}group=Note|properties_limited}} {{No}} {{No}}
Ruby {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{yes}}group=Note|properties_limited}} {{No}} {{No}}
Tcl {{yes}} {{No}} {{yes}} {{no}} {{yes}} {{no}} {{yes}} {{No}} {{No}}
TRE {{yes}} {{No}} {{No}} {{No}} {{yes}} {{No}} {{dunno}} {{No}} {{No}}
Vim {{yes}} {{no}} {{yes}} {{no}} {{no}} {{No}} {{no}} {{No}} {{yes}}
RGX {{yes}} {{yes}} {{yes}} {{yes}} {{yes}} {{no}} {{yes}} {{No}} {{No}}
XRegExp Leading only {{no}} {{no}} {{yes}} {{yes}} {{no}} {{yes}} {{No}} {{No}}
{{Reflist|group=Note|refs=[16][17][18][19][20][21][22][23][24][25]
}}

API features

API feature comparison
group=Note|unicode_nativegroup=Note|unicode_native Multi-line matchinggroup=Note|partial_match_explanation
Boost.Regex {{No}} {{No}} {{yes}} {{yes}}
GLib/GRegex {{yes}} {{yes}} {{yes}} {{yes}}
Helios RXPF {{yes}} {{yes}} {{No}} {{yes}}
ICU Regex {{yes}} {{No}} {{yes}} {{dunno}}
Java {{No}}group=Note|Partial_Uni4}} {{yes}} {{yes}}
.NETgroup=Note|UCS2}} {{yes}} {{yes}} {{dunno}}
PCREgroup=Note|8.30}} {{yes}} {{yes}} {{yes}}
Qt/QRegExp {{yes}} {{No}} {{No}} {{dunno}}
Tcl {{Yes}}group=Note|Conversion}} {{Yes}} {{dunno}}
TRE {{No}} {{dunno}} {{yes}} {{dunno}}
RGX {{No}} {{No}} {{yes}} {{dunno}}
wxWdigets::wxRegEx{{R|group=Note|wxRegEx {{yes}} {{yes}} {{yes}} {{dunno}}
XRegExp {{yes}} {{dunno}} {{yes}} {{dunno}}
{{Reflist|group=Note|refs=[26][27][28][29][30][31][32]
}}

See also

  • Regular expression § Implementations and running times

References

{{Reflist}}

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
  • [https://swtch.com/~rsc/regexp/ Implementing Regular Expressions] — series of articles by Russ Cox, author of RE2
  • Regular Expression Engines
{{DEFAULTSORT:Comparison Of Regular Expression Engines}}

3 : Pattern matching|Software comparisons|Regular expressions

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/20 15:09:25