28

Is there a list of Regex implementations on the web, showing their differences / similarities?

For exaple, Emacs elisp Regex is different to JavaScript or Perl regex, not to mention all the different implementations used by different editor software,

e.g. VS2010 uses {} instead of () to group expressions for back references.

Once upon a time I could rely on a Regex conversion list in O'Reilly's Regex Pocket Quick Reference, but something online would be so much easier, and complete.

By the way, I am aware of (of course) http://www.regular-expressions.info/ which is good, but no where near complete.

I'll compile a list from the answers posted here, and anything else I can find.

Variations

General Variations

The differences in implementations are usually the way special characters {}()[]^$ are handled (escaping rules etc.), and occasionally substituted; the handling/availability of POSIX character classes e.g. [:digit:], and the use of options, e.g. g i etc.

(a work in progress, if you know any caveats, differences for these implementations please add them as an answer)

  • ActionScript - uses ECMA style
  • Delphi (.Net) - Uses .Net style. Delphi Win32 has no native regex, but PCRE wrappers are available.
  • Emacs/ELisp - has 2 different contexts, escaping uses \\ in elisp, and \ in regexp-replace. Special chars (){}[] are escaped when using them for regex features, much like sed.
  • Eclipse - Search uses Java style regex.
  • GNU (Linux) - POSIX BRE / ERE
  • Grep - POSIX BRE / ERE
  • Groovy - Uses Java style.
  • IntelliJ
  • Java - Java style.
  • JavaScript - uses ECMA style.
  • NetBeans
  • .NET - Uses the classes in System.Text.RegularExpressions
  • Notepad++ - PCRE
  • PCRE (C/C++) - Open source library, used by many third party languages and apps. (e.g. PHP, TCL, R etc.)
  • Perl - Perl style
  • PHP - POSIX ERE, PCRE, (PHP5's multibyte string module uses Oniguruma)
  • POSIX - BRE (Basic Regex), ERE (Extended Regex)
  • PowerShell - .Net style
  • Python - Python style
  • R - POSIX ERE/BRE, PCRE
  • REALbasic - PCRE
  • Ruby - Oniguruma
  • Sed - special chars (){}[] are escaped when using them for regex features.
  • Tcl - Three flavors, Tcl ARE (advanced regex), POSIX ERE, POSIX BRE.
  • TextMate - Oniguruma
  • Tera Term - Oniguruma
  • VBScript - ECMA
  • Visual Basic 6 - ECMA (when using Microsoft VBScript Regular Expressions 5.5 COM object)
  • Visual Studio - Grouping braces are {} (more details to follow.)
  • wxWidgets - Tcl ARE, POSIX BRE/ERE
  • XML Schema - XML
  • XQuery & XPath - Xpath

Additional references.

River
  • 8,585
  • 14
  • 54
  • 67
ocodo
  • 29,401
  • 18
  • 105
  • 117
  • 1
    Yes, well that's very nice, however since we are in the profession of programming, we do tend to use the tools which serve us best, if I had the same level of support for .Net/C# in Emacs, that I do in VS2010, trust me, I'd be using it. But even with extensive yak shaving on my own time, that's really not about to happen, so ... you know, please :) – ocodo Jan 10 '11 at 08:36
  • non-free but handy http://www.regexbuddy.com/index.html – Eric Fortis Jan 10 '11 at 08:44
  • Yep, I have it for Windows, something cross platform would be good, but just the info for each implementations differences would be so useful. – ocodo Jan 10 '11 at 08:45
  • Let's not forget about Vim and its own custom flavor of regexes. More info here: http://stackoverflow.com/questions/3864467/whats-the-difference-between-vim-regex-and-normal-regex – Alexandr Kurilin Jul 29 '13 at 02:10

4 Answers4

9

Take a look at the Regular Expression Flavor Comparison on Regular-Expressions.info. It contains at least the nowadays most important regular expression implementations and their characteristics.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
4

http://www.regular-expressions.info is the closest thing I know to a comprehensive list (and even it is nowhere near complete). (This page in particular.)

Amber
  • 507,862
  • 82
  • 626
  • 550
2

I found this overview very useful when i get confused with the different variants.

funky-future
  • 3,716
  • 1
  • 30
  • 43
2

There is a list of libraries, languages and applications supporting regular expressions on Wikipedia which includes a feature comparison table:

http://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines

Stefan Schmidt
  • 3,830
  • 1
  • 24
  • 20