lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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?