Files
CHOMPStation2/code
carnie a9bea16ac8 Bygex - Regex implementation for byond.
Source-code for the dll can be found here under LGPL license:
https://github.com/Carn/bygex
It is merely an interface to boost::regex. It uses perl syntax (non-recursive).

Guidelines for use:
var/datum/regex/Rgx = regex_findall(haystack, regex_expression)
for(var/i=1, i<=Rgx.matches.len, ++i)
    world << Rgx.str(i)

The implementation is different to the one other regex-in-byond library I found. This implementation only returns a string containing the position and length of each match and submatch. This uses far less memory than also passing back the matched strings (especially in large files like dream-maker maps).

Note: Regex indexes begin at 1 (since byond lists begin at 1), unlike traditional regex. If we are using a procedure such as regex_findall(), with 3 sub-expressions, match 1 will be the overall match. Match 2 will be subexpression 1, match 3 will be subexpression 2.... Match 5 will be the overall match of the next match...and so on. To ease use, there is /datum/regex/var/anchors which is a numerical value which can be used inside loops like so:

for(var/i=1, i<=Rgx.matches.len, i+=Rgx.anchors)
    world << Rgx.str(i+1)
This will print the first submatch of each match to world.
2013-11-21 18:54:01 +00:00
..
2013-11-02 12:26:34 -07:00
2013-11-14 15:21:29 -05:00
2013-11-20 18:47:37 +10:30
2013-11-05 02:57:23 +04:00
2013-11-14 12:40:30 -05:00
2013-11-14 13:08:30 -05:00