lua-users home
lua-l archive

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


> 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.