如何使用Javascript和regex将RSS feed的description标记中的Multiple图像解析到我的描述页面

时间:2021-08-03 16:29:01

This is the sample for description tag

这是描述标记的示例

    <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 个解决方案

#1


0  

If you really have to use RegEx (which is not what you should do in the first place), then you can use this (rather simple) expression:

如果你真的必须使用RegEx(这不是你应该首先做的),那么你可以使用这个(相当简单的)表达式:

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

images now contains an array with all image tags.

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

#1


0  

If you really have to use RegEx (which is not what you should do in the first place), then you can use this (rather simple) expression:

如果你真的必须使用RegEx(这不是你应该首先做的),那么你可以使用这个(相当简单的)表达式:

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

images now contains an array with all image tags.

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