[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] xpattern.lua - regular-expression-like support via Lua patterns/code generation
- From: "David Manura" <dm.lua@...>
- Date: Sat, 22 Nov 2008 23:55:24 -0500
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.
Example:
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.
[1] http://lua-users.org/wiki/ExPattern
[2] http://lua-users.org/wiki/ListComprehensions