On my Space Station 13 server, we run a series of regexes to filter out bigoted speech.
Recently, I noticed that my most complicated regex, used to detect the n-word, would not work on upper-case text, and would only work on lowercase, as that was the case the regex was written in. Another regex, used for the same purpose, did not experience this problem, and properly followed the case-insensitive flag.
Numbered Steps to Reproduce Problem:
1. Run the code below, with your bigoted expletives of choice.
2. Be sad.
Code Snippet (if applicable) to Reproduce Problem:
var/list/pretty_filter_items = list(
for(var/pattern in pretty_filter_items)
var/regex/R = new(pattern, "ig")
if(R.Find(text)) //If found
return TRUE // Yes, it isn't pretty.
return FALSE // No, it is pretty.
var/list/expletives = list() // Fill this yourself!
for(var/word in expletives)
world.log << isnotpretty(word)
Expected Results: For the more complicated regex to obey it's "i" flag
Actual Results: A lack of case insensitivity.
Does the problem occur:
Every time? Or how often? Every time.
On other computers? Tried MoMMIv2 and the same bug occurred, yep.
When does the problem NOT occur? In the second, simple regex given.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.) This happened on my server running 512.1464, and then was confirmed by MoMMIv2 running 512.1454, so it's at least older than those versions.
It is possible to just manually add the capital versions of every letter in the regex, albeit rather tiresome.