• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Complicated regular expression. Help needed.

I'm trying to extract from the following piece of code:

<p class="clsOne">First line <a href="/page1.htm">of text</a><br>Second line <a href="/page2.htm">of text</a><br>Thrird <a href="/page3.htm">line of text</a><br></p>

What I need is everything between the two <p> tags (this I can do) but also everything seperated by a <br> excluding the <a tags>. So in this example I would have:

First line of text
Second line of text
Third line of text

Thanks and hope you can help.

Lux

0
lux_interior
Asked:
lux_interior
1 Solution
 
Michael701Commented:
have you seen this command?
strip_tags
(PHP 3>= 3.0.8, PHP 4 )

strip_tags -- Strip HTML and PHP tags from a string
Description
string strip_tags ( string str [, string allowable_tags])


This function tries to return a string with all HTML and PHP tags stripped from a given str. It errors on the side of caution in case of incomplete or bogus tags. It uses the same tag stripping state machine as the fgetss() function.

You can use the optional second parameter to specify tags which should not be stripped.

Note: allowable_tags was added in PHP 3.0.13 and PHP 4.0b3.


Example 1. strip_tags() example

$string = strip_tags($string, '<a><b><i><u>');
 
 

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now