lua-users home
lua-l archive

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


On 2015-06-15 8:37 PM, Roberto Ierusalimschy wrote:
This wouldn't quite be the same thing though, would it? I'm not seeing a
very specific definition of "punctuation" in PIL or the manual, but maybe
I'm missing it. Implementation detail? But at the very least, '%p' would
almost certainly match commas, and '%W' would include control characters,
white space, and other random things, right? Neither of those are quite a
replacement for the proposed '%m' semantics.
Why would someone need '%m'?  The motivation presented here was to
escape the magic characters.  But Lua ensures that it is safe to escape
any non-alphanumeric character, not only the magic ones. So, you can
escape anything that matches '%p' to have a valid, non-escaped pattern:

   p = string.gsub(p, "%p", "%%%0")

No need for '%m'.

-- Roberto

:o)  I guess I missed that line reading the manual

s2 = string.gsub(s, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0")
s1 = string.gsub(s, "%p", "%%%0")

I was in the mood to do something like the first line and thought it could be nice and more clean to have a symbol for the magic subset....

:-)