[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Idea about recurse pattern matching (%r)
- From: Xavier Wang <weasley.wx@...>
- Date: Tue, 6 Nov 2012 16:13:23 +0800
Hi list,
I'm working on lunicode (under development now), and I take out
Lua5.2.1's lstrlib.c and modify/refactor it (to fix support unicode).
when i'm adding unicode support in match, I have a idea.
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. all
captures in %r sub-pattern is dropped. only use it to match
multi-pattern in pattern.
has someone interesting it? or is it a good idea about Lua5.3/6? hope
for your comments :-)
--
regards,
Xavier Wang.