tgstation/-tg-station — pull request #2527 by Carn (2014-01-27 09:24:19+00:00)
Title: bygex: regex for byond.

Regex is a robust text-parsing mini-language. It can perform complex and dynamic searches and return the results in an easy to read format. This implementation also uses Boost's extended formatting syntax which gives you a flexible way to conditionally replace complex strings with only a few lines of code (most of the time just one!)

Source code and license info can be found here: http://code.google.com/p/byond-regex/
Licensed under LGPL.

This uses the perl regex syntax (with some extensions) in non-recursive mode (as recursing infers additional overheads).

Information on this syntax can be found here: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

There are many introductions to regex on the internet. Here is the one I learned from: http://www.regular-expressions.info/tutorial.html

Note: I have added #define USE_BYGEX in code/_compile_options.dm as this is not tested on a live server yet. simply comment out the define if you encounter any problems. You can also use #define USE_BYGEX "demo" to enable the demo verbs.

Due to byond being unable to communicate with a dll through anything but C-strings, the results are returned to byond in a string similar to those you get with list2params. Since byond uses parameters a lot, its params2list() proc is fairly streamlined, so it's pretty much the fastest way you could do this with byond. This data is then stored in a datum/regex object for easy use. See demo.dm datum/regex/proc/report() for an example.

ONLY A WINDOWS DLL IS PROVIDED. Source can be found at the above link, linux users will need to compile it themselves. (remember to statically link the required libraries, or it will not work!)