lua-users home
lua-l archive

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


On Feb 7, 2018, at 5:49 PM, albertmcchan <albertmcchan@yahoo.com> wrote:

> to make re.anywhere more convenient, i added = prefix in re.lua for anywhere search
> this produce very readable lpeg re pattern
> 
> t = 'this and that and whatever'
> 
> -- search for end position of that
> = re.match(t, "= 'that'")
> 14
> 
> -- search for start and end of 'that'
> = re.match(t, "=({} 'that' {})")
> 10      14
> 
> -- lua pattern ".*and(.*)"
> = re.match(t, "(= 'and')+ {.*}")
> whatever

reply to myself, =name already have meaning, so above patch will fail lpeg test.lua

maybe using '>' instead for anywhere search ?