There seems to be a bug with C# regexes. In particular, the regex "[ -_]"
seems to match capital letters. Anyone know if this is indeed a bug? It certainly seems so to me.
Buggy Code
using System;
public class Program
{
public static void Main()
{
Console.WriteLine(System.Text.RegularExpressions.Regex.Replace("Aa-_", "[ -_]", "x"));
}
}
Output: xaxx Expected: Aaxx
Non Buggy Code
using System;
public class Program
{
public static void Main()
{
Console.WriteLine(System.Text.RegularExpressions.Regex.Replace("Aa-_", "[ _-]", "x"));
}
}
Output = Expected: Aaxx
Notes
I used https://dotnetfiddle.net/ to evaluate my expressions. I got the same results as my local VS.