开发者

Regular expression to remove/replace a query string RSS feed content block

开发者 https://www.devze.com 2023-04-11 19:37 出处:网络
I am pulling in an rss feed from my blog, however I wish to remove the query string that wordpress adds to the end of my images.

I am pulling in an rss feed from my blog, however I wish to remove the query string that wordpress adds to the end of my images.

So far I have tried a number of regular expressions but so far have not been able to come up with one that will remove the ?w=400&h=222from the content block in the cdata section of the rss feed.

Any ideas guys?

Thanks

[EDIT]

the cdata section of the feed looks like this:

<![CDATA[
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis nec ullamcorper ma开发者_运维百科ssa. Fusce in nibh nulla, id viverra mi. Aliquam consectetur, nisl eget mattis porta, lorem felis lacinia orci, non malesuada lacus nibh sed dui. Praesent blandit erat id tortor fringilla commodo suscipit urna ultricies. Proin facilisis rutrum ligula ac venenatis.</p>
<div id="attachment_2255" class="wp-caption alignnone"><img src="http://myBlog.files.wordpress.com/2011/10/image.jpg?w=400&#038;h=222" alt="Image" class="size-full wp-image-2255" /><p class="wp-caption-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis nec ullamcorper massa. Fusce in nibh nulla, id viverra mi. Aliquam consectetur, nisl eget mattis porta, lorem felis lacinia orci, non malesuada lacus nibh sed dui. Praesent blandit erat id tortor fringilla commodo suscipit urna ultricies. Proin facilisis rutrum ligula ac venenatis.</p>]]>


Not tested, but this would be my first attempt...

\?w=[0-9]+&h=[0-9]+

EDIT: After your edit, I see the input data has changed. Mine answer was based on finding a match to ?w=400&h=222

&#038; is an escape sequence for an ampersand. Try the following if the first does not work...

\?w=[0-9]+&#038;h=[0-9]+
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号