lua-users home
lua-l archive

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


Wouldn't this be a lookahead for three characters and a "$", and if so, match three characters? That should work perfectly fine in LPeg.

On Sun, Oct 22, 2017 at 8:04 PM Jonathan Goble <jcgoble3@gmail.com> wrote:
On Sun, Oct 22, 2017 at 8:40 PM Sean Conner <sean@conman.org> wrote:
It was thus said that the Great szbnwer@gmail.com once stated:
> hi all! :)
>
> 2017-10-22 1:21 GMT+02:00 Charles Heywood <vandor2012@gmail.com>:
> >> Lua’s standard library includes regular expressions library
> >
> > I think it's a good idea to mention LPeg possibly becoming a part of the
> > language, but Lua itself doesn't have regex - it has Lua patterns.
>
> can you tell me more about this one?

  I think it was first brought up in 2014 on this list:

        http://lua-users.org/lists/lua-l/2014-03/msg00065.html

but I seem to recall it coming up a few times, with even Roberto mentioning
it could be possible to include with Lua, or have it replace the current Lua
patterns.

  I use LPeg a lot, but I don't have a strong opinion on including it with
the stock Lua distribution.  It would be nice, but I know where to find it.
It would likely remain its own module (much like io or os is in the current
Lua distribution).

  -spc

While I have no objection to including LPeg with the standard Lua distribution, I would strongly object to having it replace the current patterns. The beauty of the current patterns is their simplicity and easy learning curve. I find neither to be true about LPeg. I've tried to use LPeg a few times, and I find it to be confusing and not at all intuitive. In part, the use of single letters for function names leaves me scratching my head, and I can never remember what operators mean what. LPeg is powerful, yes, so I can see how it is useful. But if added to the stock Lua distribution, it should be its own standard library module (preferably with longer and more descriptive function names), without replacing patterns.

Also, unless I misunderstood something or something has changed since I last looked at it, LPeg cannot do anything requiring backtracking, so there are things matchable by patterns but unmatchable by LPeg. Possible example being "capture the three characters between a question mark and a dollar sign, immediately before the dollar sign", for which the (untested) pattern "%?.-([^$][^$][^$])%$" should match easily, but AFAICT, there is no equivalent LPeg pattern since the only way is to match up to the $ and then back up three characters.

If I am misunderstanding something, I invite somebody to correct and educate me.
--
--
Ryan | Charles <vandor2012@gmail.com>
Software Developer / System Administrator
https://hashbang.sh