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

    Join Date
    Sep 2010
    Posts
    1
    Rep Power
    0

    Can somebody solve this regex problem?


    Hi

    Imagine you have a string like this:
    xxxx<DIV id=message_xxxx><DIV id=quote>Quote: xxxx</DIV>yyyy</DIV>xxxx<DIV id=message_xxxx>yyyy</DIV>xxxx<DIV id=message_xxxx><DIV id=quote>Quote: xxxx</DIV>yyyy</DIV>xxxx<DIV id=message_xxxx><DIV id=quote>Quote: xxxx</DIV>yyyy</DIV>xxxx<DIV id=message_xxxx>yyyy</DIV>xxxx

    The xxxx and yyyy rapresents a random string that can be of any length. All xxxx and yyyy are different from one another.

    Can somebody write a regular expression that will extract all yyyy parts from the above string?
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,112
    Rep Power
    9398
    PCRE.
    Code:
    #<DIV.*?>(?:(?R)?(.*?))</DIV>#s
    The big assumption is that the single nested DIV (if there is one) is the very first thing inside the parent DIV.

IMN logo majestic logo threadwatch logo seochat tools logo