Re: how to translate lua pattern "(.*)and(.*)" with lpeg re ?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: how to translate lua pattern "(.*)and(.*)" with lpeg re ?
- From: Nick Gammon <nick@...>
- Date: 2018年1月21日 12:17:28 +1100
On 21/01/18 12:04, albertmcchan wrote:
looks like it is not easy to convert lua pattern "(.*)and(.*)" after all
my last attempt, re.compile "{(!'and' .)*} 'and' {.*}" was close, but still wrong
the re pattern correspond to lua pattern "(.-)and(.*)", not the greedy version.
What is your example input?
When I try:
require "re"
target = "foo and bar"
local re_pat = re.compile "{ (!'and' .)*} 'and' {.*}"
print (lpeg.match (re_pat, target))
I get "foo bar" as the output. Is that not what you expect?