List Info

Thread: Capturing last two matches




Capturing last two matches
user name
2006-09-26 13:47:54
Hello,

I'm new, so please be patient. I'm using PHP to read in
HTML from a DB.
The HTML itself starts and ends with the BODY tag. There is
a mix of
HTML tags within that.

What I'm trying to do is find a way to only grab the last
two
paragraphs within the BODY tags. The text itself may have
line breaks.
A (basic) sample looks like this:

<BODY><p>This is paragraph one. The quick brown
fox jumped over the
burning fence</p>
<p>This is the second<p><p>This is the
third paragraph. Talk about
repetition</p><p>This is the second last
paragraph</p>
<p>This is the last paragraph</p>
</BODY>

So ideally I want to get (with or without a line-break):

<p>This is the second last paragraph</p>
<p>This is the last paragraph</p>

Whether other tags (apart from the <p> tags) within
the results are
preserved or stripped is not a concern for me. I just need
to have the
text.

This should be easy (I hope) but I can't figure it out.

Any advice, suggestions, help etc. appreciated.

Thanks,
Michael


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )