From 4eb4419163dd6c97665b9481e9581ff32496b392 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 22 Jun 2023 10:50:15 -0300 Subject: Accumulator pattern added to the 're' module --- test.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test.lua') diff --git a/test.lua b/test.lua index 7e61603..d0b82da 100755 --- a/test.lua +++ b/test.lua @@ -1517,6 +1517,13 @@ c = re.compile([[ ]], {tonumber = tonumber, add = function (a,b) return a + b end}) assert(c:match("3 401 50") == 3 + 401 + 50) +-- test for accumulator captures +c = re.compile([[ + S <- number (%s+ number >> add)* + number <- %d+ -> tonumber +]], {tonumber = tonumber, add = function (a,b) return a + b end}) +assert(c:match("3 401 50") == 3 + 401 + 50) + -- tests for look-ahead captures x = {re.match("alo", "&(&{.}) !{'b'} {&(...)} &{..} {...} {!.}")} checkeq(x, {"", "alo", ""}) -- cgit v1.2.3-55-g6feb