lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Isn't the lesson here just to always escape your regexp patterns. (Even though
Lua isn't precisely a regexp.) But it's an age-old problem.

function string.escape(s) return (s:gsub("[%(%)%[%]%^%$%.%?%*%-]","%%%0")) end

I suppose it's easy to forget that - is a special character in Lua patterns.

--
tom <telliamed@whoopdedo.org>


string.find also supports the "plain" parameter to disable pattern matching.

Yeah, the default mode of text searching in our IDE uses the 4th param to turn off patterns.

Lua pattern based searching is a very handy advanced option that just happened to be enabled when I pasted in that search query and stepped on this computational landmine. 

DT