string "search and replace" using a .NET regex
Posted
by rsturim
on Stack Overflow
See other posts from Stack Overflow
or by rsturim
Published on 2010-03-26T19:42:27Z
Indexed on
2010/03/26
21:33 UTC
Read the original article
Hit count: 435
I need to do a 2 rule "replace" -- my rules are, replace all open parens, "(" with a hyphen "-" and strip out all closing parens ")".
So for example this:
"foobar(baz2)" would become
"foobar-baz2"
I currently do it like this -- but, my hunch regex would be cleaner.
myString.Replace("(", "-").Replace(")", "");
© Stack Overflow or respective owner