lua-users home
lua-l archive

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


/number skips captures with no values, whereas /string counts them. Example:

    > (Cg(Cc"foo", "z") * Cb"z" / 1):match"" --> "foo"

    > (Cg(Cc"foo", "z") * Cb"z" / "%1"):match""
    stdin:2: no values in capture index 1

    > (Cg(Cc"foo", "z") * Cb"z" / "%2"):match"" --> "foo"

In a similar vein, while Cf complains if the first capture is empty, a
Cg whose only captures are empty will behave as if there were no
captures in it, and produce his whole match...

    > Cg(Cc""/{}*1):match"R" --> "R"

but

    > Cf(Cc""/{}*C(1),print):match"R"
    stdin:1: no initial value for fold capture

It would be nice if all captures could behave identically. Personally,
I'd rather have them skip these empty captures in all circumstances...

-- Pierre-Yves