LuaRocks.org had a security incident in September 2026. Read the incident report.

A pure-Lua regular expression engine

$ luarocks install lua-reg

A pure-Lua regular expression engine. Patterns are compiled to an NFA and matched in time linear in the length of the string.

Features: quantifiers ({n,m}, *, +, ?), sets and ranges ([a-z0-9], [^abc]), groups, unions (a|b) and subroutine-style backreferences (\1 .. \5). The Reg class offers matches, find, finder, findall and split. Note: ':' is the escape character (not '\').

Example:

local Reg = require "luareg"

local date = Reg "[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}"
print(date:matches "21/11/2026") --> true 21/11/2026
print(date:find "released on 21/11/2026") --> 21/11/2026 13

print(Reg "[0-9]+":findall "1, 22, 333":concat ",") --> 1,22,333
print(Reg "[0-9]{2}::[0-9]{2}":matches "10:30") --> true 10:30

Works on Lua 5.1 - 5.4 and LuaJIT.

Docs: https://github.com/Luca96/lua-reg

Versions

scm-1dev6 hours ago0 downloads
0.5.1-16 hours ago1 download

Dependencies

lua >= 5.1, < 5.5
luatable ~> 0.8

Labels

Manifests