如何使用Regex.Replace从字符串中删除数字? [英] How to remove numbers from string using Regex.Replace?
本文介绍了如何使用Regex.Replace从字符串中删除数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用 Regex.Replace
从字符串中删除所有数字和符号。
I need to use Regex.Replace
to remove all numbers and signs from a string.
示例输入: 123- abcd33
示例输出: abcd
推荐答案
尝试以下操作:
var output = Regex.Replace(input, @"[\d-]", string.Empty);
\d
标识符与任何数字字符。
The \d
identifier simply matches any digit character.
这篇关于如何使用Regex.Replace从字符串中删除数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文