[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPeg: inserting previous captures by substitution
- From: Patrick Donnelly <batrick@...>
- Date: Fri, 24 Jul 2015 16:23:07 -0400
On Fri, Jul 24, 2015 at 2:45 PM, Александр Машин <alex.mashin@gmail.com> wrote:
> But what if I want to return "6000000|6 000 000"? Can I memorise the
> original capture, before removing the spaces and insert it by substitution
> after processed string? I mean, can I do it with pure re syntax, without
> function captures?
Use this:
integer <- { int }
int <- {~ digits spaces -> '' int / digits ~}
That gives you two captures, the first is the unmodified (unsubstituted) match:
print(patt:match("6 000 000")) --> 6 000 000 6000000
--
Patrick Donnelly