So I wrote a program that uses string.gmatch(). So first I define a variable text = "Number_Star" and t = {} then I do for word in string.gmatch(text,"%w+") do table.insert(t,word) end what happen is that this end up splitting. So instead of being t[1] = "Number_Star" it is now t[1] ="Number" and t[2] = "Star". I was wondering is there away to connect them through string.gmatch() or is there a way to disable these special char "_" in read()?
string.gmatch() help
Started by HurricaneCoder, Jun 08 2013 11:28 PM
2 replies to this topic
#1
Posted 08 June 2013 - 11:28 PM
#2
Posted 08 June 2013 - 11:32 PM
You can have character groupings using []. Instead of matching with the string "%w+", you would do "[%w_]+", meaning "one or more matches of any letter or digit, or an underscore."
#3
Posted 08 June 2013 - 11:33 PM
To capture anything not a space, try "%S+" or "([^%s]+)".
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











