[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to translate lua pattern "(.*)and(.*)" with lpeg re ?
- From: albertmcchan <albertmcchan@...>
- Date: Thu, 25 Jan 2018 09:33:01 -0500
this version "remove" all a's, and match only 'nd':
pat = re.compile ([[
line <- match_and+ -> drop3 {.*}
match_and <- remove_a match_nd
remove_a <- [^a]* . 'a'*
match_nd <- 'nd' / . match_and
]], { drop3 = function(s) return string.sub(s, 1, -4) end }
)
I tried building the same re pattern without recursive grammar, but failed.