lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 20/06/2011 11.46, Dirk Laurie wrote:
On Sun, Jun 19, 2011 at 04:28:01PM +0200, Ben Kelly wrote:
This results in the surprising and annoying situation that with lua patterns,
you can describe some languages that you cannot describe with regular
expressions, but at the same time there are many regular languages that you
cannot describe with lua patterns.
It neither suprises nor annoys me that Lua has found elegant and
readable ways of allowing you to do what in other languages requires
methods that are neither.

Lua patterns give a quick-and-easy solution to 99% of the stuff a
casual user needs, and the fact that the mistake of overworking the
backslash is avoided, means that one can read a Lua pattern instead
of laboriously having to decode it.

For those who need more power inside Lua, there is always LPEG, which
makes regular expressions look tired and obsolete.

Yes, I appreciate the expressive power of Lpeg (although I don't understand its syntax very much). The problem is (but maybe it's just me) its steep learning curve and the lack of tutorials.

Moreover PCRE-like regexps are extremely common, so knowing how to use them is likely to be a very "reusable" knowlegde (ranging from other programming languages to utility programs), whereas Lpeg is a "Lua-only" tool (so the effort to learn it must be really counterbalanced by the benefits one can achieve).

Nevertheless, I admit regexps are somewhat ugly to write and *really* ugly to read (especially when you didn't write them in the first place)!

Regular expressions are like stout: great for those who've learned to
love it, but repugnant to others.  And there is always an Irish pub
around the corner called "Perl".