Trying to do some regex matching and replacement in a string, whereby all ampersand, single quote, and space characters are replaced with dashes “-“
…and
all repeating dashes are replaced with a single dash.
This is what I’m trying but it’s not working, in that the repeating dashes aren’t being substituted. Any help is appreciated and thanks.
Regex.Replace(mystring, "([' &])|([-]{2,})", "-")
Try this one (seems more simple). I’m assuming you never want “–” in the result.
output: