[nycphp-talk] regexp for URLs (is this correct?)
Daniel Convissor
danielc at analysisandsolutions.com
Mon May 3 17:41:26 EDT 2004
On Mon, May 03, 2004 at 02:32:38PM -0700, Chris Hubbard wrote:
> "^((http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z0-9]{2,5}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\\\+&%\$#\=~])*)$";
You're over escaping things. Items in [] don't need to be escaped, and to
search for "-" itself, put it at the beginning or the end, [a-zA-Z0-9.-],
so it doesn't think you're creating another range.
Also, I don't think ":" needs escaping and you can change your delimiter
from "/" to some other character that's unused in the expression so you
don't have to do "\/" over and over.
... snip, the polite thing to do ...
--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