SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Regex Help

  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regex Help

    Ive always had trouble with regex it seems but I am trying to make something to pull out a number from html page. This is what the html I want to pull looks like:

    Code:
    <span class="btext">
    Ignore this text <span class="redbtext">1827</span> and this text.
    </span>
    I need to pull out the number 1827 from this block of html. I have been trying to modify this regex that pulls out the url in a <a href= link. I have included it below. Any help is greatly appreciated!

    PHP Code:
    preg_match_all("'<\s*a\s.*?href\s*=\s*
            ([\"\'])?
            (?(1) (.*?)\\1 | ([^\s\>]+))
            'isx"
    ,$document,$links); 
    Thanks again!

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about

    PHP Code:
    preg_match('|<span class="redbtext">(\d+)</span>|'$document$links
    www.SQLrecipes.com A free cookbook for SQL recipes.

    I didn't believe someone could make over $19,000 a month...
    ...with Google Adsense, until I read this.


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
  •