NYCPHP Meetup

NYPHP.org

[nycphp-talk] A good PCRE expression for matching URLs

Daniel Convissor danielc at analysisandsolutions.com
Thu Jul 24 16:22:33 EDT 2008


On Thu, Jul 24, 2008 at 02:19:58PM -0400, Michael B Allen wrote:
> Does anyone have a good PCRE for matching URLs?

Here's an ereg expression I wrote many years ago:

eregi_replace("(http://|https://|ftp://|gopher://|news:|mailto:)([[:alnum:]/!#$%&'()*+,.:;=?@_~-]+)([[:alnum:]/!#$%&'()*+:;=?@_~-])", 
'<a href="\\1\\2\\3">\\1\\2\\3</a>', $Val);

--Dan

-- 
 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
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list