PDA

View Full Version : Validate Hyperlink with Regular Expression


dominicall
05-02-2003, 08:27 PM
Hey all...

Just a quickie... anyone got a good regular expression for validating the link entered by a user in a form.

Have constructed something myself but it's a bit loose (well very loose actually - LOL) and was wondering if anyone had a good one or could point me in the right direction to get one.

Thanks

dominicall

liorean
05-02-2003, 08:38 PM
See <http://regxlib.com/>. You'll probably have to convert them to the JavaScript form.

Since a link validation regex can be written to be more or less strict and more or less complete, it's hard to tell what would be the best one for you. Also, you might want to use a contextual expression instead (you'll have to use a function for that, and it'll not be fast.), since a regex for the full case could get really big.

dominicall
05-02-2003, 08:51 PM
Thanks - have been there already so decided to stay with something that's a bit tighter than mine was but still pretty loose....

dominicall