I\'m looking for a neat RegEx solution to replace
For anyone still strugging (like me...) after the above more expert replies, this works in Visual Studio 2019:
outputString = Regex.Replace(inputString, @"\W", "_");
Remember to add
using System.Text.RegularExpressions;