lua-users home
lua-l archive

Re: String search: the need for a "literal" pattern

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


On 21/07/2011 13:08, steve donovan wrote:
function.escape(s)
 return (s:gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1'))
end
(I hope it is correct, since it is from Penlight)
Inside a character class [....], you don't have to escape characters other than:
^ - % ]
I.e., the following characters could be unescaped:
. + [ ( ) $ ? *
--
Shmuel

AltStyle によって変換されたページ (->オリジナル) /