Is Replace in C# the same as replaceAll in Java?
I’m trying to replace anything in parenthesis but it doesn’t seem to work in C#. I need the output to be just “blah”.
string username = "blah (blabla)";
userName = userName.Replace("\\([^\\(]*\\)", "");
It works when I use it here.
You are looking for the
Regex.Replace()method:The
string.Replace()method handles just that, string replacements – it does not cover regular expression.