lua-users home
lua-l archive

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


What I grapple with is

print(string.match("x","[f]"))
nil

print(string.match("x","[f]*"))

(empty string)

db

On 5/15/07, Mark Edgar <medgar123@gmail.com> wrote:
On 5/14/07, Nick Gammon <nick@gammon.com.au> wrote:
> I acknowledge that changing Lua to do this may break a whole heap of
> regular expressions currently in use, but perhaps the documentation
> could be clarified to make it clear that a period inside a char-set
> is "itself" and not "all characters".

This could be taken to be an error in PiL, since it disagrees with the
reference manual, which seems pretty clear on this:

"All classes %x described above may also be used as components in set.
All other characters in set represent themselves."

http://www.lua.org/manual/5.1/manual.html#5.4.1

It's my understanding that the reference manual is authoritative,
while PiL is not.

BTW, this is also consistent with traditional regex patterns, where
the pattern [.] also matches a literal dot.

     -Mark