Regex.Match数组使用
来源:互联网 发布:mac os cdr下载 编辑:程序博客网 时间:2024/05/10 21:05
using System.Text.RegularExpressions;
content = Regex.Match(content, "相关搜索(?<val>[\\s\\S]*?)search", RegexOptions.IgnoreCase).Groups["val"].Value.Replace("\r","").Replace("\n","");
MatchCollection TitleMatch = Regex.Matches(content, ">(?<val>[\\u4e00-\\u9fa5|\\w]*?)</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
// System.Text.RegularExpressions.Group TitleMatch = Regex.Match(content, ">(?<val>[\\u4e00-\\u9fa5|\\w]*?)</a>", RegexOptions.IgnoreCase).Groups["val"];
textBox1.Text = TitleMatch[2].Groups["val"].Value;
//下面的是取得比较正确的一个
MatchCollection TitleMatch = Regex.Matches("2.5%-15.5%", @"[\d\.]+%", RegexOptions.IgnoreCase );
、、、、注意,这里就不用转意字符\了
return TitleMatch[0].ToString();
private string remax(string chars)
{
string temp = "";
MatchCollection TitleMatch2 = null;
// MatchCollection TitleMatch = Regex.Matches("2.5%-15.5%", @"[\d\.]+%", RegexOptions.IgnoreCase );
MatchCollection TitleMatch = Regex.Matches(chars, @"[\d\.]+%", RegexOptions.IgnoreCase);
if (TitleMatch.Count > 0)
temp = TitleMatch[TitleMatch.Count - 1].ToString();
else if (TitleMatch.Count == 0)
{
TitleMatch2 = Regex.Matches(chars, @"\d+元", RegexOptions.IgnoreCase);
if (TitleMatch2.Count > 0)
temp = TitleMatch2[TitleMatch2.Count - 1].ToString();
}
return temp;
}
- Regex.Match数组使用
- Regex.Match,使用正则表达式匹配字符串
- Perl Regex: multi-line match
- C# 之 字符串截取--Regex.Match
- regex(compilation flag, sub(), non-greedy match)
- Boost.Regex 使用
- boost 库Regex使用
- Boost.Regex 使用
- 使用Regex类
- net中使用Regex
- Regex类的使用。
- Boost::Regex使用
- Regex使用心得
- VS2010 regex的使用
- Boost.Regex 使用
- C++ Regex使用
- boost regex使用详解
- boost regex的使用
- xml操作:过滤指定内容
- Android之项目推荐使用的第三方库,有助于快速开发,欢迎各位网友补充
- java单元测试(Junit)
- maven仓库和mirror关系
- fragment与activity及两个fragment之间的跳转实现
- Regex.Match数组使用
- 在Xcode项目工程中出现没有发现.pch' file not found
- glog学习
- 编程学习网址窗口
- 三级联动 省 市 区 三级联动可赋值
- 一个资深iOS开发者对于React Native的看法
- paint.setAntiAlias(true);
- 用Delphi开发视频聊天软件
- AndroidStudio插件GsonFormat快速实现JavaBean