[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Any LPEG tutorial for laymen ?
- From: Choonster TheMage <choonster.2010@...>
- Date: Tue, 24 Sep 2013 23:50:17 +1000
On 24 September 2013 23:29, Jayanth Acharya <firstname.lastname@example.org> wrote:
> On Tue, Sep 24, 2013 at 6:43 PM, Craig Barnes <email@example.com>
>> On 24 September 2013 13:07, David Crayford <firstname.lastname@example.org> wrote:
>> > I'm another layman wanting to grok LPeg. I come from a mainframe
>> > background
>> > where the lingua franca is REXX. Lua really does nuke REXX in just about
>> > every aspect other than simplicity of parsing.
>> > Take the following output from a netstat command.
>> > Client Name: SMTP Client Id: 000000B7
>> > Local Socket: 0.0.0.0..1049
>> > Foreign Socket: *..*
>> > BytesIn: 00000000000000493311
>> > BytesOut: 00000000000000366747
>> > DgramIn: 00000000000000008397
>> > DgramOut: 00000000000000008529
>> > Last Touched: 10:51:10
>> > MaxSendLim: 0000065535 MaxRecvLim: 0000065535
>> > SockOpt: D0000000 DSField: 00
>> > QOSPolicy: No
>> > RoutingPolicy: No
>> > ReceiveDataQueued: 0000000000 ReceiveMsgCnt: 0000000000
>> > I would love to learn how to write LPeg parser to yank the key->values
>> > from
>> > that multi-line report easily. I know it can be done I just can't work
>> > it
>> > out because I'm a neophyte.
>> I just threw together a rough example with LPeg, if it helps at all:
> Somewhat confused... isn't the LPEG module included using:
> and not:
> Is it the regex emulation done using LPEG ?
LPeg provides a "re" module for regular expressions. The regex string
is parsed with LPeg and translated into regular LPeg patterns.
Use `require("lpeg")` if you want to manually create all the patterns
or `require("re")` if you want to use a regular expression syntax