Complicated regular expression. Help needed.

Posted on 2005-05-01
Last Modified: 2006-11-18
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.


Question by:lux_interior
    1 Comment
    LVL 19

    Accepted Solution

    have you seen this command?
    (PHP 3>= 3.0.8, PHP 4 )

    strip_tags -- Strip HTML and PHP tags from a string
    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>');


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    This is a general how to create your own custom plugin system for your PHP application that you designed (or wish to extend a third party program to have plugin functionality that doesn't have it yet).  This is not how to make plugins for existing s…
    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now