lua-users home
lua-l archive

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

Following the discussion earlier this month [1] regarding my proposal
for a pattern token for a balanced string with an escape character, I
have now packaged the feature into a standalone module. Install with:

    luarocks install matchext

`require`ing the module returns a table with five functions: "find",
"match", "gmatch", and "gsub", which do what you expect but with the
new feature, and "monkeypatch". Calling "monkeypatch" (which takes no
arguments) will copy the four other functions into the standard
"string" table, replacing the stock functions and allowing them to be
used as methods on a string. The stock matching functions will remain
available in the "string.original" subtable (which is created by the
call to "monkeypatch"). The module does not do any automatic

I have tested that this compiles and runs in Lua 5.1, 5.2, and 5.3 on
Ubuntu 14.04 using gcc, and on Lua 5.3 on Windows 10 using Visual
Studio 2015. However, I have not extensively tested every aspect of
it. In case it doesn't compile or run properly for you (keep in mind
that I'm a noob when it comes to coding in C), bug reports (and pull
requests, if you feel so inclined) are welcome at the GitHub
repository. [2]

I hope to add additional features to this in the future (see the
LuaRocks page [3] for more details), but I make no guarantees.