I want to replace about 8 characters in a string.
Would it be more efficient to use a Regex method or just use multiple calls to string.Replace()
I’m replacing about 7 characters that may appear, all to be underscores instead. The characters could appear anywhere in the string, and not in a particular order etc.
Don’t use the Regex class unless you actually need to match a regular expression. It’s much more efficient to let the String type do straight text or character matching if that’s all your doing than to create a Regex.
The Regex class is much more powerful than simple character or string matching. This power does not come for free. Using a full regex to match a character / string is overkill. It’s the equivalent of using a high power explosive to remove a single ant from your lawn when your shoe would do just fine.