string str20 = "ABC123";
string strSplit1,strSplit2; //取出字符串中所有的英文字母
strSplit1 = Regex.Replace(str20,"[0-9]","",RegexOptions.IgnoreCase);
//取出字符串中所有的数字
strSplit2 = Regex.Replace(str20,"[a-z]","",RegexOptions.IgnoreCase);
/// <summary>
/// 从字符串中提取所有数字
/// Returns:所有数字
/// </summary>
/// <param name = "p_str"> 需要提取的字符串 </param>
/// <returns> 所有数字 </returns>
public static string GetNumbers(string p_str)
{
string strReturn = string.Empty;
if (p_str == null || p_str.Trim() == "")
{
strReturn = "";
} foreach (char chrTemp in p_str)
{
if (!Char.IsNumber(chrTemp))
{
strReturn += chrTemp.ToString();
}
}
return strReturn;
}