[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Loop through a string "lines" at a time
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 2 Jul 2007 16:02:25 -0600
Here's one way:
function loopLines(str)
local x, a, b = 1;
while x < string.len(str) do
a, b = string.find(str, '.-\n', x);
if not a then
break;
else
--Do stuff (you can use string.sub with the indicies a and b)
end;
x = b + 1;
end;
end;
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say."
-Will Durant