Comparison of regular expression engines

Comparison of regular expression engines

Contents

Libraries

List of regular expression libraries
Official website Programming language Software license
Boost.Regex [Note 1] Boost C++ Libraries C++ Boost Software License
Boost.Xpressive Boost C++ Libraries C++ Boost Software License
CL-PPCRE Edi Weitz Common Lisp BSD
cppre Jeff Stuart C++ GPL
DEELX RegExLab C++ "free for personal use and commercial use"
FREJ [Note 2] Fuzzy Regular Expressions for Java Java LGPL
GLib/GRegex [Note 3] Marco Barisione C LGPL
GRETA Microsoft Research C++ ?
ICU International Components for Unicode C/C++/Java ICU license
Jakarta/Regexp The Apache Jakarta Project Java Apache License
JRegex JRegex Java BSD
Oniguruma Kosako C BSD
Pattwo Stevesoft Java (compatible with Java 1.0) LGPL
PCRE Philip Hazel C/C++[Note 4] BSD
Qt/QRegExp [2] C++ Qt GNU GPL v. 3.0 / Qt GNU LGPL v. 2.1 / Qt Commercial
regex - Henry Spencer's regular expression libraries ArgList C BSD
re2 Google Code C++ BSD
TRE [Note 2] Ville Laurikari C BSD
TPerlRegEx TPerlRegEx VCL Component Object Pascal MPLv1.1
TRegExpr RegExp Studio Object Pascal double licensed: Freeware or LGPL with static linking exception
RGX RGX C++ based component library P6R license
  1. ^ formerly called Regex++
  2. ^ a b one of fuzzy regular expression engines
  3. ^ included since version 2.13.0
  4. ^ C++ bindings were developed by Google and became officially part of PCRE in 2006

Languages

List of languages and frameworks coming with regular expression support
Language Official website Software license Remarks
.NET MSDN Proprietary
C++ since ISO14822:2011(e)
D D Boost Software License[Note 1]
Go Golang.org BSD-style license
Haskell Haskell.org BSD3 Not included in the language report; nor in GHC's Hierarchical Libraries
Java Java GNU General Public License REs are written as strings in source code (all backslashes must be doubled, hurting readability).
JavaScript/ECMAScript
? Limited but REs are first-class citizens of the language with a specific /.../mod syntax.
Lua Lua.org MIT License Uses a simplified, limited dialect. Can be bound to a more powerful library, like PCRE or an alternative parser like LPeg.
Object Pascal (Free Pascal) www.freepascal.org LGPL with static linking exception Free Pascal 2.6+ ships with TRegExpr from Sorokin as well as with 2 other regular expression libraries. See http://wiki.lazarus.freepascal.org/Regexpr
Objective-C (Cocoa on iOS only) Apple Proprietary Currently only available on iOS 4+
OCaml Caml LGPL
Perl Perl.com Artistic License or the GNU General Public License Full, central part of the language.
PHP PHP.net PHP License Has two implementations, with PCRE being the more efficient (speed, functionalities).
Python python.org Python Software Foundation License
Ruby ruby-doc.org GNU Library General Public License Ruby 1.8 and 1.9 use different engines; Ruby 1.9 integrates Oniguruma.
SAP ABAP SAP.com ?
Tcl 8.4 tcl.tk Tcl/Tk License
(Permissive, similar to BSD)

ActionScript 3 ? ?

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 classes Non-greedy quantifiers[Note 1] Shy groups[Note 2] Recursion Lookahead Lookbehind Backreferences[Note 3] >9 indexable captures
Boost.Regex Yes Yes Yes Yes Yes [Note 4] Yes Yes Yes Yes
Boost.Xpressive Yes Yes Yes Yes Yes [Note 5] 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
FREJ No [Note 6] No Some [Note 6] Yes No No No Yes Yes
GLib/GRegex Yes ? Yes ? No ? ? ? ?
GNU Grep Yes Yes Yes Yes No Yes Yes Yes ?
Haskell Yes Yes Yes Yes No Yes Yes Yes Yes
Java Yes Yes Yes Yes No Yes Yes Yes Yes
ICU Regex Yes Yes Yes Yes No Yes Yes Yes Yes
JGsoft Yes Yes Yes Yes No Yes Yes Yes Yes
.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 ? ?
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 No 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 Yes Yes Yes Yes Yes Yes Yes Yes Yes
TRE Yes Yes Yes Yes No No No Yes No
Vim 7.3a  (2010-05-24) Yes Yes Yes Yes No Yes Yes Yes No
RGX Yes Yes Yes Yes No Yes Yes Yes Yes
TRegExpr Yes ? Yes ? ? ? ? ? ?
  1. ^ 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
  2. ^ Shy groups, also called non-capturing groups cannot be referred to with backreferences; non-capturing groups are used to speed up matching where the groups content needs not be accessed later.
  3. ^ 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"
  4. ^ 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
  5. ^ 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
  6. ^ a b FREJ have no repetitive quantifiers, but have "optional" element which behaves similar to simple "?" quantifier

Part 2

Language feature comparison (part 2)
Directives [Note 1] Conditionals Atomic groups [Note 2] Named capture [Note 3] Comments Embedded code Partial matching[clarification needed] Fuzzy matching Unicode property support [3]
Boost.Regex Yes Yes Yes Yes Yes No Yes No Some [Note 4] [Note 5]
Boost.Xpressive Yes No Yes Yes Yes No Yes No No
CL-PPCRE Yes Yes Yes Yes Yes Yes ? No No
EmEditor Yes Yes ? ? Yes No Yes No ?
FREJ No No Yes Yes Yes No No Yes ?
GLib/GRegex Yes Yes Yes Yes Yes No Yes No Some [Note 4] [Note 5]
GNU Grep Yes Yes ? Yes Yes No ? No No
Haskell ? ? ? ? ? No ? No No
Java Yes No Yes Yes [Note 6] No No ? No Some [Note 5]
ICU Regex Yes No Yes No Yes No No No Yes [Note 7]
JGsoft Yes Yes Yes Yes Yes No Yes ? Some [Note 5]
.NET Yes Yes Yes Yes Yes No ? No Some [Note 5]
OCaml No No No No No No ? No No
OmniOutliner 3.6.2 ? ? ? ? No No ? No ?
PCRE Yes Yes Yes Yes [Note 8] Yes Yes Yes No Some [Note 4] [Note 5]
Perl Yes Yes Yes Yes [Note 9] Yes Yes No No Yes [Note 7]
PHP Yes Yes Yes Yes Yes No No No No
Python Yes Yes No Yes Yes No Yes No No
Qt/QRegExp No No No No No No Yes No No
re2 Yes No  ? Yes No No Yes No Some [Note 5]
Ruby Yes No Yes Yes Yes Yes No No Some [Note 5]
TRE Yes No No No Yes No No Yes ?
Vim 7.3a  (2010-05-24) Yes No Yes No No No Yes No No
RGX Yes Yes Yes Yes Yes No No No Yes
  1. ^ Also known as Flags modifiers or Option letters. Example pattern: "(?i:test)"
  2. ^ Also called Independent sub-expressions
  3. ^ Similar to back references but with names instead of indices
  4. ^ a b c Requires optional Unicode support enabled.
  5. ^ a b c d e f g h Supports only a subset of Unicode properties, not all of them.
  6. ^ Available as of JDK7.
  7. ^ a b Supports all Unicode properties, including non-binary properties.
  8. ^ Available as of PCRE 7.0 (as of PCRE 4.0 with Python-like syntax (?P<name>...))
  9. ^ Available as of perl 5.9.5

API features

API feature comparison
Native UTF-16 support Native UTF-8 support Non-linear input support Dot-matches-newline option Anchor-matches-newline option
Boost.Regex No No Yes Yes Yes
GLib/GRegex No Yes [Note 1] No Yes Yes
ICU Regex Yes No Yes Yes Yes
Java Yes No Yes Yes Yes
.NET No [Note 2] No Yes Yes Yes
PCRE No Yes [Note 1] No Yes Yes
Qt/QRegExp Yes No No No No
TRE No ? Yes Yes Yes
RGX No No ? Yes Yes
  1. ^ Cite error: Invalid <ref> tag; no text was provided for refs named unicode_optional_1; see Help:Cite errors/Cite error references no text
  2. ^ Implementation is incorrect - it treats UTF-16 code units as characters, so characters outside the BMP don't work properly. See, for example, this bug report [1].

See also

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Regular expression — In computing, a regular expression provides a concise and flexible means for matching (specifying and recognizing) strings of text, such as particular characters, words, or patterns of characters. Abbreviations for regular expression include… …   Wikipedia

  • List of regular expression software — The following is a list of software applications that use regular expressions. In some cases, only later versions of the applications use regular expressions.ApplicationsWeb based applications See also * Comparison of regular expression engines… …   Wikipedia

  • Comparison of email clients — The following tables compare general and technical features of a number of e mail client programs. Please see the individual products articles for further information. This article is not all inclusive or necessarily up to date. Contents 1… …   Wikipedia

  • Comparison of e-mail clients — The following tables compare general and technical information between a number of e mail client programs. Please see the individual products articles (if they have one) for further information. This article is not all inclusive or necessarily up …   Wikipedia

  • Comparison of web application frameworks — This is a comparison of notable web application frameworks. Contents 1 General 1.1 Perl 1.2 PHP 1.3 Java 1.4 Python …   Wikipedia

  • JavaScript syntax — This article is part of the JavaScript series. JavaScript JavaScript syntax JavaScript topics This box: view · …   Wikipedia

  • Web crawler — For the search engine of the same name, see WebCrawler. For the fictional robots called Skutters, see Red Dwarf characters#The Skutters. Not to be confused with offline reader. A Web crawler is a computer program that browses the World Wide Web… …   Wikipedia

  • WebKit — Developer(s) Apple, KDE, Nokia, Google, RIM, Palm, Samsung, others. Initial release November 4, 1998; 13 years ago …   Wikipedia

  • C++0x — is the planned new standard for the C++ programming language. It is intended to replace the existing C++ standard, ISO/IEC 14882, which was published in 1998 and updated in 2003. These predecessors are informally known as C++98 and C++03. The new …   Wikipedia

  • Entity–attribute–value model — (EAV) is a data model to describe entities where the number of attributes (properties, parameters) that can be used to describe them is potentially vast, but the number that will actually apply to a given entity is relatively modest. In… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”