C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
生活随笔
收集整理的這篇文章主要介紹了
C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
///?去掉字符串中的數字??
????????public?static?string?RemoveNumber(string?key)??
????????{??
????????????return?Regex.Replace(key,?@"\d",?"");??
????????}??
//去掉字符串中的非數字
public?static?string?RemoveNotNumber(string?key)??
{??
????return?Regex.Replace(key,?@"[^\d]*",?"");??
} ?
????????public?static?string?RemoveNumber(string?key)??
????????{??
????????????return?Regex.Replace(key,?@"\d",?"");??
????????}??
//去掉字符串中的非數字
public?static?string?RemoveNotNumber(string?key)??
{??
????return?Regex.Replace(key,?@"[^\d]*",?"");??
} ?
轉載于:https://www.cnblogs.com/94cool/p/4332957.html
總結
以上是生活随笔為你收集整理的C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 复制网页自动追加文字js
- 下一篇: c#学习笔记之第一个程序“Hello w