ID:2338673
 
Resolved
A fix to some regular expressions both didn't go far enough and also broke others.
BYOND Version:512.1404
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Firefox 57.0
Applies to:Dream Daemon
Status: Resolved (512.1405)

This issue has been resolved.
The regex changes in 1404 appear to have had unintended side-effects. I've reduced it to this example, which works fine in 1403 but runtimes in 1404.

/world/New()
var/regex/trimQuotesRegex = new/regex({"^\[\\s\n]+"?|"?\[\\s\n]+$|^"|"$"}, "g")

var/string = {" "name" "}
var/trimmed = trimQuotesRegex.Replace(string, "")

var/obj/o = new
o.vars[trimmed] = "meme object"
world.log << "[o]"


It seems like trimmed has the value "name " instead of the more sensible "name", but I can't see any obvious reason as to why.
mob/verb/regextest()
var/regex/test = new/regex(@"^(?:\x2F(?:_|\l)\w*)+$","gm") var/phrase = "/obj\n/obj/some\n/obj/some/thing"
var/count = 0
while(test.Find(phrase))
world.log << "[++count]: [test.match]"
world.log << "[count] matches"


The above should be returning three matches.

I'm getting zero.
I did some digging and was able to figure out that something in the later expression that explained a bit.

It looks like from the outset, because I was using the same instruction to handle non-capturing group closes as "nothing"--used in some branches and particularly in with some modifiers like * and + and so on, that's what caused the problem with non-capturing groups to begin with--but the fix for that changed the way that instruction was interpreted, which messed up all kinds of other stuff. Ugh.

I have a solution but it's really inelegant, so I'm hoping I can find a better way around it than that. However I'll probably go with that for the short term at least since it works.
https://github.com/google/re2/tree/master/re2/testing has a bunch of regex unit tests if you ever needed something like that
Lummox JR resolved issue with message:
A fix to some regular expressions both didn't go far enough and also broke others.