[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Regexp library
- From: Reuben Thomas <rrt1001@...>
- Date: Sat, 18 Nov 2000 04:53:06 +0000 (GMT)
I've just finished the first cut of a POSIX regexp library for Lua. It
simply exposes the POSIX regcomp and regexp functions (regfree is hidden in
a gc tag method). The functions provided are:
regex(p): returns the compiled regex (a userdata) corresponding to the
pattern p (a string)
match(t, r): returns a triplet of start position, end position, table of
substring matches for the text string t and compiled regex r.
It seems slightly more useful to have regex than not, because a regex can
then be used repeatedly (it wouldn't be awfully inefficient to reimplement
gsub with it).
One last feature, untested as yet: if you have Henry Spencer's regex
library, then NULs are allowed in the pattern and text.
If anyone would like the source for this library (about 3Kb) please email
me; I'll make it available on my Lua page soon, along with the bitwise
operations library I posted to the list earlier.
http://sc3d.org/rrt/ | impatience, n. the urge to do nothing