盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

解读C#中的正则表达式

时间:2024/10/28作者:未知来源:盾怪网教程人气:

[摘要]\.\d+)";   MatchCollection mc14 = Regex.Matches(t14, p14); 找出所有的大写字母string t15 = "...
\.\d+)";
  
    MatchCollection mc14 = Regex.Matches(t14, p14);
  
找出所有的大写字母

string t15 = "This IS a Test OF ALL Caps";
  
    string p15 = @"(\b[^\Wa-z0-9_]+\b)";
  
    MatchCollection mc15 = Regex.Matches(t15, p15);
  
找出小写的单词

string t16 = "This is A Test of lowercase";
  
    string p16 = @"(\b[^\WA-Z0-9_]+\b)";
  
    MatchCollection mc16 = Regex.Matches(t16, p16);
  
找出第一个字母为大写的单词

string t17 = "This is A Test of Initial Caps";
  
    string p17 = @"(\b[^\Wa-z0-9_][^\WA-Z0-9_]*\b)";
  
    MatchCollection mc17 = Regex.Matches(t17, p17);
  
找出简单的HTML语言中的链接


string t18 = @"
  
    <html>
  
    <a href=""first.htm"">first tag text</a>
  
    <a href=""next.htm"">next tag text</a>
  
    </html>
  
    ";
  
    string p18 = @"<A[^>]*?HREF\s*=\s*[""']?" + @"([^'"" >]+?)[ '""]?>";
  
    MatchCollection mc18 = Regex.Matches(t18, p18, "si");



关键词:解读C#中的正则表达式




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版