lua-users home
lua-l archive

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


Hi Sean,

>   I've simplified the LPeg code.  What I want is the behavior of this:
>
>         delim  = P"/"
>         field  = C((P(1) - delim)^0)
>         regexp = Ct(
>                        delim
>                      * Cg(field,"re")
>                      * delim
>                      * Cg(field,"replace")
>                      * delim
>                      * Cg(field^-1,"flags")
>                    )
>
> But where delim is defined as the first character of the string (instead of
> the hardcoded pattern I have here).  This is harder than it looks.

Cb matches the empty string, not the literal value of the capture (from your original code). You need to use matchtime captures to solve your problem. See the Lua longstring example in the lpeg docs.

- Patrick