SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Mike Borozdin's Avatar
    Join Date
    Oct 2002
    Location
    Edinburgh, UK
    Posts
    1,743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question RegEx help needed!

    Hi!

    I need to get all the text between <div> and </div> that doesn't contain any tags except for <br />, for example:

    HTML Code:
    <div>
    gfgfgf<br />gfgg
    </div>
    How do I do that?

  2. #2
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    preg_match('=<div>(.*)</div>=i'$search$match);
    $result strip_tags($match[1], '<br />'); 
    not quite sure about the index in $match, should be either 0 or 1

  3. #3
    SitePoint Wizard Mike Borozdin's Avatar
    Join Date
    Oct 2002
    Location
    Edinburgh, UK
    Posts
    1,743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, but I want to grab the div contents that DOESN' have any tags except <br /> and don't remove tags.

  4. #4
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops This is gonna be more difficult i think, and more than i can do with regexps, sorry

  5. #5
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Daimaju
    PHP Code:
    preg_match('=<div>(.*)</div>=i'$search$match);
    $result strip_tags($match[1], '<br />'); 
    not quite sure about the index in $match, should be either 0 or 1
    It'd be 0. ($match[0])


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •