[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Any LPEG tutorial for laymen ?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 24 Sep 2013 09:51:23 -0300
> Take the following output from a netstat command.
>
> Client Name: SMTP Client Id: 000000B7
[...]
>
> I would love to learn how to write LPeg parser to yank the key->values
> from that multi-line report easily.
You don't need LPeg for this task. Try
for k,v in T:gmatch("(%u[%w ]-):%s*(.-)%s") do print(k,v) end
where T contains the netstat output.
But don't let that discourage you from learning LPeg. There is nothing
more effective for learning than concrete motivation.