[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to translate lua pattern "(.*)and(.*)" with lpeg re ?
 
- From: Sean Conner <sean@...>
 
- Date: Sat, 20 Jan 2018 21:29:04 -0500
 
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