pregmatch() question?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wren9
Forum Newbie
Posts: 9
Joined: Sat May 23, 2009 1:50 am

pregmatch() question?

Post by wren9 »

I have these codes below,

Code: Select all

 
<?php
//include methods/class
include_once 'simple_html_dom.php';
include_once 'casting.inc.php';
 
 
// Create DOM from URL
$url = "http://sampledomain.org/tlg/";
$html = file_get_html($url);
 
// Find all links
// connect exact url and make it live link
foreach($html->find('a') as $element) {
    #echo "<b>" . $element->href . "</b><br>"; 
    
    //check if href has /html/ if yes then connect right live url
    if(preg_match("/tlg/", $element->href)) {
        if(preg_match("/html/", $element->href)) {
            $atlanta_url['url'] = $element->href;
            echo $atlanta_url['url'] ."<br>";
        }
    }
 
}
 
         
?>
 
The result of that codes you will see below,
http://czone01.com/onstaged/scrape_craig_old.php

I don't understand why these strings below, still included?
rose1.2515
daisy0.7525
orchid1.157

It suppose to be excluded since the pregmatch() should limit that.

Anybody would like to help me figure that out please?

Is this a pregmatch() flaw?

Thanks in advance.
Last edited by Benjamin on Tue May 26, 2009 10:54 am, edited 1 time in total.
Reason: Changed code type from text to php.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: pregmatch() question?

Post by jmut »

I suggest you give simple string , tell us what pattern you look for and your try code. This way you'll get much better response.
Cheers
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: pregmatch() question?

Post by prometheuzz »

wren9 wrote:....

Is this a pregmatch() flaw?

...
I don't understand you question, but it is highly unlikely that someone not familiar with regular expressions (you in this case) finds a bug in PHP's preg_match function. So, could you explain your problem without me needing to some external url in order to see what's going wrong?

Good luck.
Post Reply