lua-users home
lua-l archive

Re: lpeg.C() drops named captures. Is there a workaround for that?

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


> [...] 
> So: I understand what is happening, and why it happens... but is there
> a workaround? Is it possible to replace the :C():Cg"c" in
> 
> pabc = (P"(%" * pa * pb * P")"):C():Cg"c":Ct()
> 
> by something else, that would put the substring matched by the
> 
> P"(%" * pa * pb * P")"
> 
> into the key "c" without dropping the named captures generated by pa
> and pb?
I myself tend to use named captures nested in table captures only for
very simple tasks. For anything more complex I prefer to use unamed
captures nested in function captures: The function then creates the
table with the proper fields.
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /