Given a regex that can successfully match nothing, (with the "g"lobal flag) replacetext will freeze the world. Interestingly, the UI remains responsive, but executing other verbs does nothing.
Additionally, manually looping through such a regex does not match the final position in the string. (See Test4 below)
Code Snippet (if applicable) to Reproduce Problem:
client/verb
Test1()
world << replacetext("aaaaaaaa", regex(""), "N")
// Actual: "Naaaaaaaa". Correct!
Test2()
world << replacetext("Hello_World", regex("_*", "g"), "")
// Actual: Freezes the world (but not the UI)
// Expected: "HelloWorld" See: https://regex101.com/r/hL6tY3/1
Test3()
world << replacetext("aaaaaaaa", regex("()", "g"), "N") // Used "()" instead of "" because of Regex101
// Actual: Freezes the world (but not the UI)
// Expected: "NaNaNaNaNaNaNaNaN" Batman! See: https://regex101.com/r/cH0fY9/1
Test4()
var/regex/R = regex("()", "g")
world << "Match at positions: \..."
while(R.Find("hi"))
world << "[R.index] \..."
world << ""
// Actual: "Match at positions: 1 2"
// Expected: "Match at positions: 1 2 3" See: https://regex101.com/r/mC6fU7/1
Disclaimer:
I recognize some of the examples are silly, but I wanted them to be fairly minimal. In my particular case, I needed to match any leading whitespace, followed by an optional quotation mark. Since both parts were optional, it lead to the world freezing.