lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
So, I want to separate the comma separated tokens, trim the left and 
right whitespace, and preserve the white space in the middle.
    
ws = lpeg.P'*'
sep = lpeg.P','
elem = ws^0 * lpeg.C((ws^0 * (1 - ws - sep)^1)^0) * ws^0
p = elem * (sep * elem)^0
  
That definitely works.  I need to pick through the elem line to understand why, and if I have questions, I'll ask them.

I know LPeg has been in the works for a short time period, but for newbies like me, a growing collection of LPeg snippets would be very useful.  These really help.

Thanks!

Josh