lua gsub madness (Help pls)
Posted: Thu Apr 18, 2019 7:29 pm
I'm making an ingame code editor, but i'm not very good at using string.gsub
Here is my problem:
returns:
that the number inside quotes is colored is not so critical, but i could really use some help with the quotation bug
edit: i'm now using this piece of madness:
Here is my problem:
Code: Select all
--numbers
result = string.gsub(result,"%f[%d%a]%d+%f[%c%p%s]","[color=255,128,0]%1[/color]")
--strings
result = string.gsub(result,"\"[%a%d%s%p]+\"","[color=64,64,64]%1[/color]")edit: i'm now using this piece of madness:
Code: Select all
abc983=-1
result = string.gsub(result,"\"",function(input)
abc983=abc983+1
if abc983%2==0 then
return "quotationopen_"..math.floor(abc983/2).."_983"
else
return "quotationclose_"..math.floor(abc983/2).."_983"
end
end)
for i=0, abc983/2 do
result = string.gsub(result,"quotationopen_"..i.."_983[%a%d%s%p]+quotationclose_"..i.."_983","[color=64,64,64]%1[/color]")
result = string.gsub(result,"quotationopen_"..i.."_983","\"")
result = string.gsub(result,"quotationclose_"..i.."_983","\"")
end