[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Idea about recurse pattern matching (%r)
- From: Egor Skriptunoff <egor.skriptunoff@...>
- Date: Tue, 6 Nov 2012 20:20:36 +0300
On 11/6/12, Xavier Wang <weasley.wx@gmail.com> wrote:
> now Lua don't support ?,*,+,- on a so-called sub-pattern, but from the
> source, to add this support is easy: we can add a special %r (means
> recurse) modifier, so as:
> ("catcatcat"):match "%r(cat)+"
> returns
> catcatcat
> the idea is call match repeatly with sub-pattern on subject
I like the idea of using subpatterns in patterns.
Would it be more convenient to use curly braces instead of %r()?
I also want to get captures from any subpattern.
("Abracadabra"):match "({([Aa])bra{ca()d}?}+)"
returns
Abracadabra A 7 a