Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个正则表达式
[A-Za-z]
和一个字符串,例如
你好!这是一个字符串。
我想用空格替换所有不在正则表达式中的字符。所以,我会结束
嗨,这是一个字符串
这是怎么做到的?
var cleaned = Regex.Replace(given, "[^A-Za-z]", " ");
尝试:
string output = Regex.Replace(input, "[^A-Za-z]", " ");