本文實(shí)例講述了C#基于正則表達(dá)式刪除字符串中數(shù)字或非數(shù)字的方法。分享給大家供大家參考,具體如下:
/// 去掉字符串中的數(shù)字public static string RemoveNumber(string key){ return Regex.Replace(key, @"/d", "");}//去掉字符串中的非數(shù)字public static string RemoveNotNumber(string key){ return Regex.Replace(key, @"[^/d]*", "");}
希望本文所述對(duì)大家C#程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注