我有一个正则表达式
[A-Za-z]
和一个字符串,如
Hi! This is a string.
我想用空格替换所有不在正则表达式中的字符.所以,我最终会
Hi This is a string
这是怎么做到的?
解决方法
var cleaned = Regex.Replace(given,"[^A-Za-z]"," ");
[A-Za-z]
和一个字符串,如
Hi! This is a string.
我想用空格替换所有不在正则表达式中的字符.所以,我最终会
Hi This is a string
这是怎么做到的?
var cleaned = Regex.Replace(given,"[^A-Za-z]"," ");