lundi 23 février 2015

Lua: split string into words unless quoted

So I have the following code to split a string between whitespaces:



text = "I am 'the text'"
for string in text:gmatch("%S+") do
print(string)
end


The result:



I
am
'the
text'


But I need to do this:



I
am
the text --[[yep, without the quotes]]


How can I do this?


Edit: just to complement the question, the idea is to pass parameters from a program to another program. Here is the pull request that I am working, currently in review: http://ift.tt/1zzAD7w


Aucun commentaire:

Enregistrer un commentaire