|
On Monday, October 07, 2013 11:31:35 AM Dan Tull wrote:
> I originally just sent this to our internal Lua mailing list, but thought it
> was an amusing little tale that I'd pass along.
>
> The Lightroom codebase uses these kinds of separator lines for headers and
> such:
>
> --[[------------------------------------------------------------------------
> ----
>
> ----------------------------------------------------------------------------
> ]]--
>
> I had invoked a search with one of the closing kind as part of the selection
> and our IDE (which has an option to search code using a Lua pattern) went
> into a tailspin.
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>