I know precisely zilch about regular expressions and figured this was as good an opportunity as any to learn at least the most basic of basics.
How do I do this case-insensitive string replacement in C# using a regular expression?
myString.Replace("/kg", "").Replace("/KG", "");
(Note that the ‘/’ is a literal.)
You can use:
If you’re going to do this a lot of times, you could do:
Using
(?i:/kg)would make just that bit of a larger regular expression case insensitive – personally I prefer to useRegexOptionsto make an option affect the whole pattern.MSDN has pretty reasonable documentation of .NET regular expressions.