我的正则表达式的使用方法
2005-02-25 08:50
399 查看
我的正则表达式的使用方法:
//匹配路径
string regexStrPath = "/b[a-z]://[^/:*?"<>|/r/n]*";
//匹配时间、大小和文件名
string regexStrInfo = "(?<time>/d/d-/d/d-/d/d/s+/d/d/:/d/d)/s+(?<size>[/d|,]+)/s+(?<name>[/S|/.]+)";
MatchCollection mcPath = Regex.Match(yourString, regexStrPath, RegexOptions.IgnoreCase);//忽略大小写
foreach(Match m in mcPath)
{
string path = m.Value; //路径
}
MatchCollcetion mcInfo = Regex.Match(yourString, regexStrInfo, RegexOptions.IgnoreCase);
foreach(Match m in mcInfo)
{
string name = m.Group["name"].Value;
string size = m.Group["size"].Value;
string time = m.Group["time"].Value;
}
//匹配路径
string regexStrPath = "/b[a-z]://[^/:*?"<>|/r/n]*";
//匹配时间、大小和文件名
string regexStrInfo = "(?<time>/d/d-/d/d-/d/d/s+/d/d/:/d/d)/s+(?<size>[/d|,]+)/s+(?<name>[/S|/.]+)";
MatchCollection mcPath = Regex.Match(yourString, regexStrPath, RegexOptions.IgnoreCase);//忽略大小写
foreach(Match m in mcPath)
{
string path = m.Value; //路径
}
MatchCollcetion mcInfo = Regex.Match(yourString, regexStrInfo, RegexOptions.IgnoreCase);
foreach(Match m in mcInfo)
{
string name = m.Group["name"].Value;
string size = m.Group["size"].Value;
string time = m.Group["time"].Value;
}
相关文章推荐
- php使用正则表达式获取图片url的方法
- JS使用replace()方法和正则表达式进行字符串的搜索与替换实例
- JS中的正则表达式小小的技巧---Test方法的使用
- JS使用replace()方法和正则表达式进行字符串的搜索与替换实例
- C# 中使用正则表达式 Regex.Matches方法的几个应用[转]
- Linux学习-grep与正则表达式使用方法
- Java使用正则表达式删除所有HTML标签的方法示例
- php使用正则表达式去掉html中的注释方法
- qt中的正则表达式QRegExp使用大全以及匹配中括号[]方法
- 正则表达式学习笔记(一)——使用正则表达式的分析方法
- 使用 jQuery 验证密码一致性,正则表达式验证邮箱及手机号的方法
- WinForm使用正则表达式提取内容的方法示例
- 举例说明在android中使用正则表达式去掉字符串中标点符号及其他一些特殊符号的方法
- ExtJS4的文本框(textField)使用正则表达式进行验证(Regex)的方法
- 【JAVA正则表达式使用方法】
- iOS中正则表达式的基本使用方法
- JS字符串替换函数全部替换方法 JS 正则表达式如何使用变量
- 使用JS中的exec()方法构造正则表达式验证
- ASP.NET 常用的正则表达式(使用C#3.0扩展方法)
- 正则表达式基本使用方法