[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Iterating over string with delimiter that is multiple occurrences of the same character
- From: Andrew Starks <andrew.starks@...>
- Date: Fri, 11 Oct 2013 09:02:52 -0500
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.