C# 使用正则表达式去掉字符串中的数字
2012-08-08 13:32
381 查看
/// <summary>
/// 去掉字符串中的数字
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string RemoveNumber(string key)
{
return System.Text.RegularExpressions.Regex.Replace(key, @"\d", "");
}
/// <summary>
/// 去掉字符串中的非数字
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string RemoveNotNumber(string key)
{
return System.Text.RegularExpressions.Regex.Replace(key, @"[^\d]*", "");
}
/// 去掉字符串中的数字
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string RemoveNumber(string key)
{
return System.Text.RegularExpressions.Regex.Replace(key, @"\d", "");
}
/// <summary>
/// 去掉字符串中的非数字
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string RemoveNotNumber(string key)
{
return System.Text.RegularExpressions.Regex.Replace(key, @"[^\d]*", "");
}
相关文章推荐
- C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
- C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
- C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
- C# 使用正则表达式去掉字符串中的数字
- C# 使用正则表达式去掉字符串中的数字
- C# 使用正则表达式去掉字符串中的数字
- C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中
- C# .net 使用正则表达式去掉字符串中的数字
- 【转】C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
- C# 使用正则表达式判断字符串是否由英文或数字组成
- C#正则表达式基础 {3} 检测字符串是否存在 3个连续的数字
- 举例说明如何使用正则表达式去掉字符串中的一些特殊符号
- C#中使用正则表达式验证电话号码、手机号、身份证号、数字和邮编
- c#使用正则表达式匹配字符串验证URL示例
- C#中使用正则表达式验证电话号码、手机号、身份证号、数字和邮编验证电话号码的主要代码如下:
- C#使用正则表达式检测数字 char 和韩文
- C#使用正则表达式去除字符串中的多个不同大小的空格
- C#中使用正则表达式验证电话号码、手机号、身份证号、数字和邮编
- C#正则表达式基础 {3,} 检测字符串是否存在 3个以上 相邻的数字
- C#使用正则表达式将数字转换为大写中文