好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

C#基于正则表达式删除字符串中数字或非数字的方法

本文实例讲述了C#基于正则表达式删除字符串中数字或非数字的方法。分享给大家供大家参考,具体如下:

?

/// 去掉字符串中的数字

public static string RemoveNumber( string key)

{

   return Regex.Replace(key, @"\d" , "" );

}

//去掉字符串中的非数字

public static string RemoveNotNumber( string key)

{

   return Regex.Replace(key, @"[^\d]*" , "" );

}

希望本文所述对大家C#程序设计有所帮助。

dy("nrwz");

查看更多关于C#基于正则表达式删除字符串中数字或非数字的方法的详细内容...

  阅读:47次