我试图从字符串
中删除特定的标点符号我只需保留字符串" .
"," ,
"," !
&#34 ;," +
"," *
"," -
"但删除所有内容,包括撇号和#34;"""例如
what's up!
必须是:
whats up!
所以这样,它会删除所有内容
string res = Regex.Replace(filtr2, @"[^\w\s]", "");
答案 0 :(得分:1)
希望您正在寻找类似的东西:
string rexFormat=@"[^0-9a-zA-Z\.,!+\-* \w ]";
string myInPutString ="what'sup ! my dear friend?";
string replacedString = Regex.Replace(myInPutString, rexFormat, string.Empty);
// will give you whatsup ! my dear friend
删除了特殊字符'
和?