Soo what im trying to do is split a string with multiple lines into a table with each line. soo i searched on the wiki and it seems like i need to use the %s pattern the problem is that from my understanding that pattern is also for spaces is there a way for new lines only?
Im probably an idiot as i never use string patterns for anything
For this you will have to do some patternizing, and it's a bit hard to do, but this will do.
function linesplit(inputstr) local t={} ; i=1 for str in string.gmatch(inputstr, "([^\n]+)") do t[i] = str i = i + 1 end return t end
There's unicode symbols that you can use when using patterns, such as "\n
" which is new line.
Notepad uses "\t
", which is also another way of new line.
If you'd ever like to use a space, you have to use "%s
".
You should go check some Unicode symbols and Patterns here: http://lua-users.org/wiki/SplitJoin