1. 程式人生 > >分別獲取一個字符串中的字母和數字

分別獲取一個字符串中的字母和數字

string ons ase 動態生成 repl brush 取出 str logs

 string    str20   =   "ABC123";   
 string   strSplit1=string.Empty;
 string   strSplit2=string.Empty;   
    
  //取出字符串中所有的數字   
  strSplit1   =   Regex.Replace(str20,"[a-z]","",RegexOptions.IgnoreCase);   


  //取出字符串中所有的英文字母   
  strSplit2   =   Regex.Replace(str20,"[0-9]","",RegexOptions.IgnoreCase);  

 這個方法挺實用的,解決了很多動態生成序列號一系列問題;

分別獲取一個字符串中的字母和數字