#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Match html li elements with nested br tag


    How do I return the contents of all li elements when there are other tags (br, p, etc) within it before the closing tag is reached. For example ... with this data:

    <li>Testhere and here</li>
    <li>Test here2 and<br> there 2</li>
    <li>Test here and there3</li>

    I have tried this regular expression:

    !<li>(?P<category1>[^(</li>)]*)</li>!

    but it only returns the first and third list element ... how do I get all three?

    Thanks in advance
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    spaceBAR Central
    Posts
    229
    Rep Power
    42
    This should match all 3 of the example lines you gave:
    Code:
    <li>(?P<category1>.*)</li>

IMN logo majestic logo threadwatch logo seochat tools logo