Re: Add to regex help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux