<!-- publish_helper name='原始正文' p_id='6' t_id='12' d_id='5225186' f_id='41' --><p>  青少年<p><div style="text-align:center"><img alt="刘继在比赛中" src="http://i1.sinaimg.cn/ty/2010/0929/2010929101036.jpg" style="border:px solid #000000" title="刘继在比赛中" /></div><div style="margin: 5px 0; text-align: center;">刘继在比赛中</div><p>  陈彦p>
<!-- publish_helper_end -->
上面是html,我想读取中间的文本,可不可以根据“<!-- publish_helper ”“<!-- publish_helper_end -->”来取???
可以的话正则怎么去?
对了,图片路径怎么取?
谢谢!小弟正则不懂...

解决方案 »

  1.   

    不好意思...忘了说明了
    最后的结果<p>  青少年<p><div style="text-align:center"><img alt="刘继在比赛中" src="http://i1.sinaimg.cn/ty/2010/0929/2010929101036.jpg" style="border:px solid #000000" title="刘继在比赛中" /></div><div style="margin: 5px 0; text-align: center;">刘继在比赛中</div><p>  陈彦p>
      

  2.   

    对了,如果
    <!-- publish_helper name='原始正文' p_id='6' t_id='12' d_id='5225186' f_id='41' -->
    有时候会是<!-- publish_helper name='原始正文' -->
    那正则写一个可以么?
      

  3.   

    这样?            Regex regBody = new Regex(@"(?is)<!-- publish_helper[^>]*>.*?<!-- publish_helper_end -->");
                Regex regTag = new Regex(@"<[^>]*>");
                Match m = regBody.Match(yourStr);
                if (m.Success)
                {
                    richTextBox2.Text = regTag.Replace(m.Value, "");
                }
      

  4.   

    哦,那就没必要做二次处理了            Regex regBody = new Regex(@"(?is)<!-- publish_helper[^>]*>(.*?)<!-- publish_helper_end -->");
                Match m = regBody.Match(yourStr);
                if (m.Success)
                {
                    richTextBox2.Text = m.Groups[1].Value;
                }
      

  5.   

    Regex regex = new Regex(@"<!?--.*?>", RegexOptions.IgnoreCase);
    string content = regex.Replace(content ,"");
      

  6.   

    最后一个问题,如果运行成功结贴...
    超链接<a href="**">好</a>
    有时候超链接是<a href="***" style="****">好</a>
    超链接前面和后面都有代码,我只想取消了超链接的html标签,但是“好”要留下...请问正则怎么写!!
    谢谢!
      

  7.   

    刚反应过来,一直等你回话,原来你在等我要最后的结果啊,呵呵!
    我要的是
    <img alt="刘继在比赛中" src="http://i1.sinaimg.cn/ty/2010/0929/2010929101036.jpg" style="border:px solid #000000" title="刘继在比赛中" />
    要改为
    <img alt="刘继在比赛中" src="本项目的一个文件的路径/2010929101036.jpg" style="border:px solid #000000" title="刘继在比赛中" />
    但是有的链接有style有的没有
    谢谢!!!
      

  8.   


    Regex reg = new Regex(@"(?is)<a[^>]*>(.*?)</a>");
    string result = reg.Replace(yourStr, "$1");
    richTextBox2.Text = result;
      

  9.   


    string test = "<img alt=\"刘继在比赛中\" src=\"http://i1.sinaimg.cn/ty/2010/0929/2010929101036.jpg\" style=\"border:px solid #000000\" title=\"刘继在比赛中\" />";
    Regex reg = new Regex(@"(?is)(?<=<img[^>]*?src=(['""]?))[^'""\s>]*(?=/[^'""\s>/]+\1[^>]*>)");
    string result = reg.Replace(test, "本项目的一个文件的路径");
    richTextBox2.Text = result;
      

  10.   

    MatchCollection mc = Regex.Matches(yourStr, @"(?<=<(?:input|img)(?:(?!src)[\s\S])*src=(['""]?))[^""'\s>]*(?=\1)", RegexOptions.IgnoreCase);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Value + "\n";
    }这个对不??
      

  11.   

    你给我的正则对了,但是因为图片原本是网络的如:<img src="http://www.baidu.com/images/1.jpg">
    你给我的能够替换为<img src="本地路径+图片本身的名称">
    但是现在图片还没有保存到本地,我想先获取网络的图片路径“http://www.baidu.com/images/1.jpg”,我写好了保存本地的方法了,就差网络的路径了 ....