#Paper Posted July 19, 2011 Posted July 19, 2011 i have this code: if string.find(g_MapInfo.name, "[DM]", 1, false) then g_MapInfo.name = string.gsub(g_MapInfo.name, '[DM]', '#ff0000[DM]#236B8E') end instead to be: [DM] lol it becomes: [[DM][DM]] lol How to fix?
Uisaqin Posted July 19, 2011 Posted July 19, 2011 try if string.find(g_MapInfo.name, "[DM]", 1, true) then -- disable pattern matching on [ ] g_MapInfo.name = string.gsub(g_MapInfo.name, '%[DM%]', '#ff0000[DM]#236B8E') -- escape [ ] with %[ %] end
#Paper Posted July 19, 2011 Author Posted July 19, 2011 try if string.find(g_MapInfo.name, "[DM]", 1, true) then -- disable pattern matching on [ ] g_MapInfo.name = string.gsub(g_MapInfo.name, '%[DM%]', '#ff0000[DM]#236B8E') -- escape [ ] with %[ %] end omfg it works D: Btw what changes if i use the %?? D:
Aibo Posted July 19, 2011 Posted July 19, 2011 [ and ] are special characters used to denote a character set in a pattern. "[DM]" is a pattern and it means "D or M". that's why special characters must be escaped with %.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now