lua-users home
lua-l archive

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


local C, P = lpeg.C, lpeg.P

-- my attempt for lua pettern "(.+)and(.*)"
local lpeg_pat = C((P(1) - 'and')^1) * 'and' * C(P(1)^0)
local re_pat = re.compile "{ (. ! 'and')* . } 'and' {.*}"

-- lua pattern "(.*)and(.*)
lpeg_pat = C((P(1) - 'and')^0) 'and' * C(P(1)^0)

-- what is lpeg re equivalent code ?