lua-users home
lua-l archive

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



On 12/12/14 11:33 AM, Luiz Henrique de Figueiredo wrote:
Can I do that with a for loop?
S="The quick brown fox jumps over the lazy dog"

for a,b in S:gmatch("(%S+)%s+(%S+)") do
	print(a,b)
end


Ok what I want is more like

for a,b in S:gmatch("()%S+()") do

BUT I also want string.find-like results:

local from, to, match1, match2 = S:find("(%S+) (%S+)")

Can I get

S="The quick brown fox jumps over the lazy dog"
for from, to, match1, match2 in <something> do
  print(from, to, match1, match2)
end
--[[
1	9	The	quick
11	19	brown	fox
21	30	jumps	over
32	39	the	lazy
]]

(I find it more intuitive than `for from, match1, match2, to`)

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.