View Full Version : URL Validation
06-08-2007, 02:31 PM
var w = new RegExp();
Also, can anyone recode this so that the following url would also work..
Can anyone help?
06-08-2007, 02:40 PM
add the ~ to the regualr expression than
06-08-2007, 02:55 PM
Thanks. I tried that but it didnt seem to work. What about the other url using a sub domain rather than www ?
06-08-2007, 03:11 PM
change [www]+ to (www)?
06-08-2007, 03:36 PM
I am not sure how you have derived your regex but it is completely wrong.
e.g. [www] means match w or w or w, not www.
The “safe” characters in a URL are alphanumerics (A to Z, a to z and 0 to 9) and the following special characters: the dollar sign (“$”), hyphen (“-”), underscore (“_”), period (“.”), plus sign (“+”), exclamation point (“!”), asterisk (“*”), apostrophe (“'”), left parenthesis (“(”), and right parenthesis (“)”).
The regex you desire (i.e. validate a URL) is:-
& and ? cannot normally appear as part of a URL except in query string.
A tilde ~ is not "safe" character but I have included it. A space should be encoded as %20
What is w.compile supposed to do?
In fact it may be simpler and just as effective to just check the starting characters in the URL up to www.
You can test your regular expressions at: http://www.ogauge.co.uk/regextester.html
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.