PCRE/PHP regex not matching last "item"

Posted by superbarney on Stack Overflow See other posts from Stack Overflow or by superbarney
Published on 2012-09-18T09:09:38Z Indexed on 2012/09/18 9:37 UTC
Read the original article Hit count: 351

Filed under:
|
|

Here's a regex that I've cobbled up:

/(.*={76}\s)?\s*(.*?)\s\-\-\s(\d{2}\/\d{2}\-\d{2}\s\d{2}:\d{2})\s\s(.*?)\s(http:\/\/service.*?)\s(\-{76})/is

and here's the text I will be parsing: http://p.linode.com/7015

and here's the replacement for the matched text:

<item>\n\t<title>$2</title>\n\t<pubDate>$pubDate</pubDate>\n\t<description>$4</description>\n\t<link>$5</link>\n</item>\n\n

I have almost come up with a regex needed to parse a block of text into RSS 2.0 XML markup. I've tested it with RegExr and RegexBuddy and it works perfectly except for the last "item" where there is no line breaks after the link (Line 269). In short, the problem is the "iProperty" article in the text is not matched.

Any regex gurus willing to help me troubleshoot what's wrong? I've tried

/(.*={76}\s)?\s*(.*?)\s\-\-\s(\d{2}\/\d{2}\-\d{2}\s\d{2}:\d{2})\s\s(.*?)\s(http:\/\/service.*?)\s*(\-{76})/is

Here's the output that I get: http://p.linode.com/7016

but that didn't work as I expected (i.e. a newline would be optional).

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about regex