lua-users home
lua-l archive

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


Scott:

On Tue, Aug 27, 2019 at 2:46 PM Scott Morgan <blumf@blueyonder.co.uk> wrote:
> Is there a limit to how big those sets can be? In practice I'd be
> looking at a few dozen allowed chars.

Its trivially easy to test. Assuming you only use the printable subset
of the ascii set you wanted to use:

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> a=''; for i=32,126 do a=a..string.char(i) end; print(a)
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
> b=a:gsub("([%%%-%]])","%%%1"); print(b);
 !"#$%%&'()*+,%-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\%]^_`abcdefghijklmnopqrstuvwxyz{|}~
> print(a:gsub("[^"..b.."]","x"))
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
   0
> print(a:gsub("["..b.."]","x"))
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   95

I do not have a 5.1 handy, but you can test it easily, and given how
char classes are usually made ( I haven't looked in lua, but I've seen
several ), they normally are unlimited, specially when dealing with
bytes.

Francisco Olarte.