lua-users home
lua-l archive

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


On Sat, Sep 29, 2018 at 10:38:30AM +0200, Lorenzo Donati wrote:
> On 27/09/2018 06:39, Sai Manoj Kumar Yadlapati wrote:
> > Hi all,
> > 
> > Lua supports its own version of regular expression matching.
> > But it doesn't have the | (pipe symbol) support and the quantifier support
> > - a{1,5} meaning a can occur anywhere from 1 to 5 times.
> > 
> > Both of these are present in PCRE. I am curious to know why these are not
> > supported.Is it not supported intentionally or was it never considered?

> > 
> > Thanks
> > Sai Manoj
> > 
> 
> To reinforce what Andrew said in his reply: please note that Lua patterns
> are NOT regular expressions. That is they haven't got the same expressive
> power as regexes, and that's /by design/. The goal was/is to keep Lua size
> small.
> 
> I can't say if implementing alternation (i.e. that OR operator) will
> increase Lua size by much, but I suspect it will.

I am not sure why everybody seems to believe that (non-PCRE) regular
expression engine has to be complex. See
https://swtch.com/~rsc/regexp/regexp1.html for implementation in less than
400 lines of C (probably less rewritten in a "modern" style).

> 
> -- Lorenzo
>