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