lua-users home
lua-l archive

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




On 15/06/15 07:00 PM, Brigham Toskin wrote:
On Mon, Jun 15, 2015 at 8:28 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> I'm in Lua exploration, and I want to use its pattern matching.
> Basically I read  strings form a file and use that has pattern to
> scan program code...
>
> so here my suggestion  ...
>
> Can we have a  "%m"  symbol  representing lua  "magic" characters set ?
> basically   this   "^$()%.[]*+-?"
>
> so it will be more nice to scan my source file and put exception
> characters in it.
> and  it will help writing more nice pattern when using in complex pattern

You can use %p (or, if you are an ANSI-C zealot, %W) for that job. Lua
ensures that any non-alphanumeric character can be escaped with '%' to
mean itself.

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.

I'm not sure there's really a big need for the %m character class, but it would be novel.

--
Brigham Toskin
Forward-compatible code.
-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.