Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

= About Python regexes =

Aiui "The Future of Python Regexes" SO answer at http://stackoverflow.com/a/7066413/1077672 written by regex (and Perl) expert Tom Christiansen (and last updated by him in 2012) is still good info.

In brief, https://pypi.python.org/pypi/regex appears to be the path forward for Python. This engine is much closer to the power and Unicode compatibility of Perl 5's default regex engine.

= About Perl 5 regexes =

Aiui the default Perl 5 regex engine is significantly faster than the 're' regex feature included with Python 2. I don't know how it compares to the new 'regex' module.

Regexes in Perl have the advantage/disadvantage that they are syntactically integrated in to the language (a disadvantage if you don't like it being integrated).

Since Perl 5.10, a different regex engine can be plugged in and used without requiring any change in code that uses regexes (unless an engine uses a different syntax of course). (But it takes a lot of effort to package a regex engine up for use with Perl 5.)

A given regex engine can be extended using the overload module. Extending is relatively easy.

= About Perl 6 regexes =

A whole new ball game, two decades ahead of Perl 5 regexes.

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

http://doc.perl6.org/language/grammars

https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Gra...

Generally matches Perl 5 regexes feature-for-feature but with a much cleaner syntax. More importantly, unifies regexes and grammars.

Currently way slower than Python or Perl 5 regexes. Supposedly will eventually (5 years? 10?) incorporate all the key optimizations in the Perl 5 engine and become faster than Perl 5 regexes.



Case in point, with the countdown to Perl 6 now on the cause seems hopeless:

Perl 5.20 / 19Mb Apache log file / time: 1 sec

perl -wnl -E 'say $1 if /\b(\w{5})\b/' logs.txt

Perl 6 (MoarVM 2015.02) / 19Mb Apache log file / time: 88 secs

perl6 -n -e 'say $0 if m/(<<\w5>>)/' logs.txt

Given that efficient text & regex parsing is Perl's forte I don't see Perl 6 satisfying the basic requirements of Perl 5 hackers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: