lua-users home
lua-l archive

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


Agreed... clearer, and somewhat more familiar (in standard posix regex sense). Thanks for clarifying @Craig.

However, I am also trying to comprehend the comment by @Choonster:
> Use `require("lpeg")` if you want to manually create all the patterns
> or `require("re")` if you want to use a regular _expression_ syntax
> instead.

If someone can share 2 small illustrative examples of when to use which one, or why -- it'd be excellent. I know that I am perhaps asking for too much.



On Tue, Sep 24, 2013 at 7:35 PM, Craig Barnes <craigbarnes85@gmail.com> wrote:
On 24 September 2013 14:29, Jayanth Acharya <jayachar88@gmail.com> wrote:
> Somewhat confused... isn't the LPEG module included using:
>    require("lpeg")
> and not:
>    require("re")
>
> Is it the regex emulation done using LPEG ?

Yep, it's a separate module included with LPeg[1]. It's mostly PEG
notation[2] with a few Lua specific extras. I'm not sure if it was the
best example to use but I find it much clearer to read.

[1]: http://www.inf.puc-rio.br/~roberto/lpeg/re.html
[2]: http://en.wikipedia.org/wiki/Parsing_expression_grammar#Examples