Reputation: 43
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
and finally, here's the output that I get: http://p.linode.com/7016
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?
Upvotes: 2
Views: 117
Reputation: 92
I've try and I think I've got the solution (I can generate the correct output file with it), just modify your regex like this :
/(.*={76}\s)?\s*(.*?)\s\-\-\s(\d{2}\/\d{2}\-\d{2}\s\d{2}:\d{2})\s\s(.*?)\s(http:\/\/service.*?)(\s(\-{76})|$)/is
I've just added the |$
at the end and some ()
for the OR statement.
Upvotes: 1