lua-users home
lua-l archive

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


Philippe Lhoste <PhiLho <at> GMX.net> writes:

>
> Andreas Stenius wrote:
> > I have a feature request for the string library.
> > When matching sets, I've come across the whish to match the end of the
> > subject, as an alternative in a set, so putting the $ last doesn't work,
> > since I want it inside the set, which currently doesn't work.
>
> I am not sure to understand fully.
> You want to write something like "foo([\r\n]|$)"?
> It isn't possible with the standard string library, because the regex
> engine is simple and doesn't support alternatives.
> It won't be improved toward this goal (it would need a very different
> algorithm, much bigger), so you would need either more code around the
> matching code (like I did in a parser) or to use a third party regular
> expression library (there is a PCRE binding).
>


No, not alternates like that, simply to be able to:

foo:gsub("(.-)[%s$]", bar)

which in a way works as alternates, but not to the extent as with a | operator.

//Andreas

Ps. Sorry if this mail ends up wrong in the thread (I left the mail deliveries from the list off without thinking of the concequences[sp]..)