-- $Id: nopattern1.lua,v 1.3 2008/08/26 21:59:15 hahe Exp hahe $ require "lpeg" txt = " (abc) foo" ob = lpeg.P("(") cb = lpeg.P(")") pat = (1 - ob)^0 * ob * 1^0 -- matches only (a -- because 1^0 == 1 -- this matches more: -- pat = (1 - ob)^0 * ob * lpeg.P(1)^0 pat = lpeg.C(pat) x = lpeg.match(pat, txt) print (x)