日期:2014-05-18 浏览次数:21156 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RegexEx
{
class Program
{
static void Main(string[] args)
{
string str = "Fax张楚晋";
string temp = System.Text.RegularExpressions.Regex.Replace(str, "[a-zA-Z]", "").ToString();
Console.Write("替换字母后的字符:{0}\n",temp);
System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(str, @"(?<text>(^[a-zA-Z]+))", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
if (m.Success)
{
string s = m.Groups["text"].Value.ToString();
Console.Write(s);
}
Console.Read();
}
}
}