lua-users home
lua-l archive

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


steve donovan <steve.j.donovan@gmail.com> wrote:

> It's actually why I like Lua string patterns - they are not _too_
> powerful and so you are forced to use things like if-statements, all
> that boring stuff that makes programs readable and not the inscrutable
> rantings of some ASCII god.

Except, like anything you do with repetition, it becomes much easier to
read and understand over time. Also, if you use the /x modifier you can
ignore whitespace and add comments right in the regular expression!


Russell Haley <russ.haley@gmail.com> wrote:

> "Verification issues will further cloud the picture, since regular
> expression people try to enforce constraints (like year cannot be more
> than four digits) using regular expressions, on the usual grounds that
> you shouldn’t stop using a hammer when you are enjoying yourself."
> 
> I can't stop laughing and my face hurts. :P

I actually created a PCRE[1] patch[2] since I really, really, like my hammers
due to years of perl coding. I think that patch is for Lua 5.2 though and
is one of many I plan to upgrade to the latest Lua versions this year.

I probably should look into Lua pattern matching as well, though as I knew
regular expressions it seemed silly at the time to learn yet another pattern
matching language.


~Paige

[1] PCRE = Perl Compatible Regular Expressions.   https://www.pcre.org/

[2] The patch adds the ability to parse regular expression syntax and adds
    opcodes to handle the new =~, !~, #~, and ?~ regex operators[3].

[3] Yes, I know it could be done as a loadable library, but I really wanted
    the actual regex operators, and wanted non-stringified regex patterns...
    and most importantly... for the learning experience!