Page 1 of 1

url or email

Posted: Fri Apr 15, 2005 3:47 am
by shiznatix
I need to find out of a string is either a URL or a E-mail address. I image a regular expression would do it but the only real way I could think would to check for a @ sign and if its found then its a email if not its a URL but I think that should a little sketchy. Any other ideas?

Posted: Fri Apr 15, 2005 4:10 am
by JayBird
this will match an email address

Code: Select all

^(ї0-9a-zA-Z]+ї-._+&])*ї0-9a-zA-Z]+@(ї-0-9a-zA-Z]+ї.])+їa-zA-Z]{2,6}$
this will match a url

Code: Select all

^(http|https|ftp)\://їa-zA-Z0-9\-\.]+\.їa-zA-Z]{2,3}(:їa-zA-Z0-9]*)?/?(їa-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*ї^\.\,\)\(\s]$
i think :lol:

Posted: Fri Apr 15, 2005 5:32 am
by shiznatix
thanks much