Re: Add to regex help
| From: | Silvio Porcellana | Date: | Tue, 19 Oct 2004 14:34:33 +0000 |
| Subject: | Re: Add to regex help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199808@lists.php.net to get a copy of this message | ||
Uhm, I guess you are looking for links (following a 'href') in your HTML page, so why don't you just do something like:
preg_match_all('/href=[\"\']?([^\"\'>\s]*)[\"\']?/i', $url, $matches)
(note the '\s' added inside the bracket that should match the link, as you could have:
<a href=pippo.com target=_blank> - that is, a link "terminated" by a white space)
HTH, cheers!
Silvio
Mag wrote:
Hi, Quite some time back I modified a regex (to the one below) to work with my script: if (preg_match_all('/<a\s+.*?href=[\"\']?([^\"\']*)[\"\']?[^>]*>.*?<\/a>/i', $url, $matches)){ foreach($matches as $match){$links[] = $match;} } Problem is, I dont really know REGEXs properly and dont remember how I modified it and it completly ignores the below: <area shape="rect" coords="95,8,242,145" href="2/FIVE.MPG"> because its a map and I guess it does not start with <a and does not end with </a> but I need to make sure it catches even the above... Can someone help me add to the above regex please? Thanks, Mag ===== ------ - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) _______________________________ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com