如何使用Javascript和regex将RSS源的描述标签中的多个图像解析到我的描述页面

时间:2013-09-27 07:35:55

标签: javascript regex image parsing rss

这是描述标签的样本

    <description>
    On 5th September, 2013 ICSK Junior Branch students expressed their love and respect                                for their teachers.<div align=center><img src=http://www.example.com/press//press/sep2613focus1.jpg></div> <div       align=center><img src=http://www.example.com/press//press/sep2613focus3.jpg></div>
     The  highlight of the day was address by Principal Incharge, educating children on the significance of the Day. Indeed a touching day for the teaching fraternity of ICSK. <div align=center><img src=http://www.example.com/press//press/sep2613focus4.jpg></div> More ICSK News at <a href="http://www.icsk-kw.com" target = "_blank">www.icsk-kw.com</a>
    </description>

1 个答案:

答案 0 :(得分:0)

如果你真的 使用RegEx(首先你应该做什么),那么你可以使用这个(相当简单的)表达式:< / p>

// description contains the text that you provided
images = description.match(/<img src=[^>]+>/g);

images 现在包含一个包含所有图像标记的数组。