Hi Niklas:

On Fri, Jul 26, 2002 at 01:54:25AM +0200, Nicklas af Ekenstam wrote:
> Hi
> 
> I have this regular expression:
> 
> (((http|https|ftp|gopher)|mailto):(//)?[^ <>"\t]*|www\.[-a-z0-9.]+)[^ .,;\t<">\):]
> 
> Which is supposed to match hyperlinks. I would like to use this
> from php to grab all hyperlinks in a text file and return them
> in an array.
> 
> I've messed around with the function preg_match_all() but I just
> can't seem to get it to work. Any suggestions would be very 
> appreciated.
> 
> Thanks,
> Nicklas
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

The mailing list archive:
http://groups.google.com/groups?group=php.general

Good search terms:
hyperlink "regular expression"

Yields this article:
http://groups.google.com/groups?q=hyperlink+%22regular+expression%22+group:php.general&hl=en&lr=&ie=UTF-8&safe=off&selm=3A248B2C.13ED233C%40analysisandsolutions.com&rnum=2

Which has an excellent [shamelessly patting myself on the back] hyperlink
regular expression for ereg*:

  "(http://|https://|ftp://|gopher://|news:|mailto:)
  ([[:alnum:]/!#$%&'()*+,.:;=?@~-]+)([[:alnum:]/!#$%&'()*+:;=?@~-])"

Do note, if the last character of the URI is a "," or "." it assumes those 
are punctuation and leaves them off.

Enjoy,

--Dan

-- 
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

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

Reply via email to