有没有更好的方法来替换字符串?
我很惊讶Replace不接受字符数组或字符串数组.我想我可以写自己的扩展,但我很好奇是否有更好的内置方式来执行以下操作?注意最后一个Replace是一个字符串而不是一个字符.
myString.Replace(';', '\n').Replace(',', '\n').Replace('\r', '\n').Replace('\t', '\n').Replace(' ', '\n').Replace("\n\n", "\n");
Run Code Online (Sandbox Code Playgroud) 我如何从字符串中删除字符?例如:"My name @is ,Wan.;'; Wan".
我想删除该'@', ',', '.', ';', '\''字符串中的字符,以便它成为"My name is Wan Wan"