码迷,mamicode.com
首页 > 其他好文 > 详细

如何多次提取字符串中的指定字符串

时间:2017-01-10 17:16:28      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:his   style   ons   value   多个   options   src   compile   content   

例如:从数据中获取content字符串,这个content用于前台html的显示,content中包含多个<img src="_IIMMGG_2156537">,_IIMMGG_后面的数字是imageid,每个img标签的id各不相同,如何获取content中各_IIMMGG_后面的imageid呢?

--解决方案

string tmp = this.m_PropContent;
Regex RX = new Regex(@"_IIMMGG_\-?\d+", RegexOptions.Compiled);
MatchCollection match = RX.Matches(tmp,0);
string imageId = "";

foreach(Match ma in match)
{
string strValue= ma.Value;
string strId = strValue.Replace("_IIMMGG_","");
imageId+= strId+",";
}

 

如何多次提取字符串中的指定字符串

标签:his   style   ons   value   多个   options   src   compile   content   

原文地址:http://www.cnblogs.com/chzbgb/p/6269968.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!