lua-users home
lua-l archive

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


Here is another re pattern that does NOT use recursive grammar.
It has similar performance as my split version (no lookahead)

Without recursive grammar, backtrack overhead may be smaller.
I optimize it furthur by not directly matching 'and'

pat = re.compile( 
      "((!'and' .)* ...)+ -> drop3 {.*}",
      { drop3 = function(s) return string.sub(s, 1, -4) end }
)