lua-users home
lua-l archive

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

xpattern.lua [1] is a preliminary, pure Lua implementation of
regular-expression-like support implemented in terms of a code
generation technique similar to that of [2] and reusing the Lua
patterns implementation.  It provides a syntax similar to LPeg.

local M = require "xpattern"
local m = ( (P'(b+)' + P'(c+)') * P'[A-Z][a-z]'^0 * P'(.)' ):compile()
local a,b,c = m('mmcccZzYybbZzYyddd')
assert(a == 'bb' and b == nil and c == 'd')

This approach, which the implementation provides a working
demonstration of, may have a certain niche.