PCRE/PHP regex not matching last "item"
- by superbarney
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!