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.
我正在寻找正则表达式来用空字符串替换除正斜杠或数字之外的所有字符。
我有以下内容,除了数字之外的所有内容:
Regex.Replace(time, "[^0-9]", "");
Regex.Replace(time, "[^0-9/]", "");
这应该有效。
尝试
Regex.Replace(time, "[^0-9|/]", "");
看起来[^0-9/]是正确的模式。
[^0-9/]
在 Debuggex 上实时编辑