博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#利用正则表达式获取特定格式的字串符
阅读量:4041 次
发布时间:2019-05-24

本文共 456 字,大约阅读时间需要 1 分钟。

///     /// return the first match string. use regularExpression. eg.  getMatchStr("abc1233dfdfa456","\d+")    ///     /// string    /// reg string    /// 
public string getMatchStr(string str,string regular) {
MatchCollection matchCol = Regex.Matches(str, regular); if (matchCol.Count > 0) {
return Convert.ToString(matchCol[0]);//这个例子是取第一个匹配的字符串 } else return ""; }

转载地址:http://pimdi.baihongyu.com/

你可能感兴趣的文章
iOS网页专用,打开iSecret App
查看>>
排列组合公式/排列组合计算公式
查看>>
FaceBook 代码中重要备份&nbs…
查看>>
图片处理之 截取图片
查看>>
MPMoviePlayerController使用,以…
查看>>
iSecret 官方资料
查看>>
iSecret 1.1 正在审核中
查看>>
IOS开发的开源库
查看>>
IOS开发的开源库
查看>>
iSecret 1.1 正式发布 Congratulat…
查看>>
正则表达式语法
查看>>
SQL语句求总数、求平均数、降序排…
查看>>
计算字符串中各个字符出现的次数
查看>>
双层状态栏问题 跟踪状态栏Fr…
查看>>
CGRectInset、CGRectOffset…
查看>>
总结Objective-C中CGGeometry几何…
查看>>
CPM,CPC,CPL,CPS广告术语大全
查看>>
链表反转 58面试“留念”
查看>>
我的博客今天0岁200天了,我领取了…
查看>>
layoutSubviews 和 layoutIf…
查看>>