Posted 25 May 2015 - 09:40 PM
I am attempting to sift through a string and get a number of different things out of it, but the loop that it is running in does not seem to ever end. As of posting this, I am running a test to see how many times It runs, and it has run over 150,000 times, and it is still going. This leads me to believe I have done something wrong causing it to never end.
code snippet:
What this does is convert a string like this:
"Hello[COLOR:RED]There " into 5 variables
"Hello","COLOR","RED","There"," "
pastebin for the code: http://pastebin.com/VV7mJ5Ym
My question is what is causing it to never end. Is it the multiple captures, a horrible pattern, or something else?
code snippet:
siteContents = "Anavrins [BG:BLACK]test site! [C:RED][CENTER]NOTHING IS REAL[/CENTER][CENTER][C:LIME]i'm editing this site in notepad++[/CENTER][CENTER]i made a markup language. :)/>/>/>/>[/CENTER] [BR][C:WHITE]make it rain krist wooo [BR][BR]by the way nice hat[BR][CENTER]centered text [C:RED]with color[C:WHITE] took [HL:RED]forever[HL:BLACK] to make[/CENTER][CENTER]also, the refresh button barely works[/CENTER] i'm just writing random stuff now.[BR]comp id: [ID][BR]PHP random number: 759704590[BR][C:THEMEFG]fuck shit gets its color from the theme[CR]this text[END]"
counter=0
for pword,tag,arg,aword,space in siteContents:gmatch("(%w*)%[?(%/?%w*):?(%w*)%]?(%w*)(%s*)") do -- preword, tag, argument, afterword, space
counter=counter+1
print(counter)
sleep()
end
What this does is convert a string like this:
"Hello[COLOR:RED]There " into 5 variables
"Hello","COLOR","RED","There"," "
pastebin for the code: http://pastebin.com/VV7mJ5Ym
My question is what is causing it to never end. Is it the multiple captures, a horrible pattern, or something else?
Edited on 25 May 2015 - 08:09 PM