择一匹配
2015-12-15 22:15
204 查看
| 将两个匹配条件进行逻辑“或”(Or)运算。
示例一:查找数字或字母
string findStr1 = "ad(d3)-df";
string regexFindStr = @"[a-z]|\d";
string newStrFind=String.Empty;
MatchCollection newStr = Regex.Matches(findStr1, regexFindStr);
newStr.Cast<Match>().Select(m => m.Value).ToList<string>().ForEach(i => newStrFind += i);
Console.WriteLine(findStr1 + "中的字母和数字组成的新字符串为:" + newStrFind);
示例二:将人名输出("zhangsan;lisi,wangwu.zhaoliu")
string strSplit = "zhangsan;lisi,wangwu.zhaoliu";
string regexSplitstr = @"[;]|[,]|[.]";
Regex.Split(strSplit, regexSplitstr).ToList().ForEach(i => Console.WriteLine(i));
示例一:查找数字或字母
string findStr1 = "ad(d3)-df";
string regexFindStr = @"[a-z]|\d";
string newStrFind=String.Empty;
MatchCollection newStr = Regex.Matches(findStr1, regexFindStr);
newStr.Cast<Match>().Select(m => m.Value).ToList<string>().ForEach(i => newStrFind += i);
Console.WriteLine(findStr1 + "中的字母和数字组成的新字符串为:" + newStrFind);
示例二:将人名输出("zhangsan;lisi,wangwu.zhaoliu")
string strSplit = "zhangsan;lisi,wangwu.zhaoliu";
string regexSplitstr = @"[;]|[,]|[.]";
Regex.Split(strSplit, regexSplitstr).ToList().ForEach(i => Console.WriteLine(i));
相关文章推荐
- msql 正则表达式
- 正则表达式
- Mootools 1.2教程 正则表达式
- 批处理FINDSTR正则表达式用法实例分析
- vbs正则表达式代码
- C#正则表达式Regex类的常用匹配
- C#使用正则表达式实现首字母转大写的方法
- php中看实例学正则表达式
- PHP正则表达式之定界符和原子介绍
- PHP下常用正则表达式整理
- 批处理 正则表达式(findstr) 整理
- 详解C#正则表达式Regex常用匹配
- C#正则表达式的6个简单例子
- JavaScript类型系统之正则表达式
- javascript中的正则表达式使用指南
- C#中的正则表达式介绍
- 学习正则帮手笨狼正则练习器
- java正则表达式应用的实例代码
- ruby 正则表达式 教程