lua-users home
lua-l archive

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


On Fri, Oct 11, 2013 at 8:38 AM, Mark Melling
<mark.melling@savageminds.com> wrote:
> s = "a;;b;;c"

I believe that tricks of the trade includes a similar solution to this one:


s = "sdf;sd;a;;b;;c"

for p in s:gsub(";;", "\0"):gmatch("([^\0]+)") do
   print(p)
end

I'm not aware of a way for Lua's pattern matching system to do what
you're asking for in one step (although, like you, I wouldn't be
surprised to find a simple answer from someone else.)

LPEG can do this in one step, but this might be better for such a
straightforward case.