lua-users home
lua-l archive

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


It was thus said that the Great Nick Gammon once stated:
> 
> 
> 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?

  I'm thinking the input is something like:

	this and that and the other

and albertmcchan wants

	"this and that"	"the other"

but not

	"this"	"and that and the other"

  -spc