[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Idea about recurse pattern matching (%r)
- From: Xavier Wang <weasley.wx@...>
- Date: Wed, 7 Nov 2012 01:44:14 +0800
makes subpattern support capture may complicate. so I don't plan to support it.
the issue of using braces is that, it breaks Lua's compatible. the {}
is not magic-char before, but it is now.
%r is a unused "magic" char, so we don't worry about compatibility.
2012/11/7 Egor Skriptunoff <egor.skriptunoff@gmail.com>:
> 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
>
--
regards,
Xavier Wang.