preg match help

Discussion in 'PHP' started by crazyryan, Jan 7, 2008.

  1. #1
    Anyone see whats wrong with this:
    http://pastebin.com/m1c0d37fe

    I thought it'd pick a correct match but I'm getting an error...?

    Error is:
    Warning: preg_match() [function.preg-match]: Unknown modifier ' ' in /home/donku/public_html/script.php on line 37
     
    crazyryan, Jan 7, 2008 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    I don't know what you are trying to do... perhaps you should rtfm!
     
    Kaizoku, Jan 7, 2008 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    I thought it'd be quite easy to see what I wanna do...

    Basically, I've got the file_get_contents and I wanna check if $pattern is in it?
     
    crazyryan, Jan 7, 2008 IP
  4. blacknet

    blacknet Active Member

    Messages:
    709
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    70
    #4
    don't.. use strpos or str_replace with the count param instead..
     
    blacknet, Jan 7, 2008 IP
  5. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #5
    Yeah, I looked at strpos but I eventually want to use regex so it grabs everything in that format.

    E.G
    #
    <div class="item">
    #
              <div>
    #
                                    <!--
    #
                    <a href="massive_bike_race_pileup" target="_new">
    #
                    <img src="http://204.14.123.30/content/thumb/d112008/massive_bike_race_pileup.jpg" alt="Massive Bike Race Pileup" width="120" height="100" class="thumb" border=0  />
    #
     
    #
                    </a>
    #
                    -->
    #
                                    <a href="/videos/massive_bike_race_pileup.html" >
    #
                            <img src="http://204.14.123.30/content/thumb/d112008/massive_bike_race_pileup.jpg" alt="Massive Bike Race Pileup" width="120" height="100" class="thumb" border=0  />
    #
     
    #
                    </a>
    #
                              </div>
    #
     
    #
              <h2>  <a href="/videos/massive_bike_race_pileup.html" >Massive Bike Race Pileup</a>
    #
     
    #
     </h2>
    #
                           Rate: Not rated         | Votes: 0  <br />
    #
                            Viewed: 1367 | Added: 01/01/2008 19:45<br />
    #
    Category:
    #
     
    #
    Video
    #
     
    #
    <br />
    #
    <br />
    #
     
    #
    Now THAT makes for an interesting bike race!<br /><br />
    #
     
    #
    <!--
    #
    <strong>Channel:</strong> <a href="#">Video &raquo; Funny Video</a>
    #
    -->
    #
    </div>
    Code (markup):
    So I grab the thumbnail url, description & title etc.
     
    crazyryan, Jan 7, 2008 IP
  6. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    HI,

    The issue is your pattern is invalid. A pattern should be a regex of what you are looking for.
    http://uk3.php.net/preg_match
    Take a look at how the 1st example is done. You could adapt that for what you need.
     
    lfhost, Jan 8, 2008 IP