msdn上有现成的例子,而且讲得很详细,具体什么方位我记不清了

解决方案 »

  1.   

    验证输入字符是否全部为英文字符
    System.String ex = @"^\w+$";              System.Text.RegularExpressions.Regex reg = new Regex( ex );                              bool flag = reg.IsMatch( str );验证邮件格式
    System.String ex = @"^\w+@\w+\.\w+$";System.Text.RegularExpressions.Regex reg = new Regex( ex );bool flag = reg.IsMatch( str );
    从 URL 提取协议和端口号
    String Extension(String url)    {      Regex r = new Regex(@"^(?<proto>\w+)://[^/]+?(?<port>:\d+)?/",         RegexOptions.Compiled);      return r.Match(url).Result("${proto}${port}");    }
    要得到不以数字开头的字符组合
    (?<!\d)[a-zA-Z]{2,}
      

  2.   

    http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=%2fquickstart%2fhowto%2fsamples%2fRegularExpressions%2fRegexMatch%2fRegexMatch.src
      

  3.   

    http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=%2fquickstart%2fhowto%2fsamples%2fRegularExpressions%2fRegexMatch%2fRegexMatch.src
      

  4.   


     as follows: http://expert.csdn.net/Expert/topic/1930/1930163.xml?temp=.5256006