I'm using a regex pattern that I got from regexlib to validate relative urls. On their site you can test the pattern to make sure it fits your needs. Everything works great on their site, as soon as I use the pattern in mine I get the error message:
Invalid range in character class
I know that this error usually means that a hyphen is mistakenly being used to represent a range and is not properly escaped. But in this case since it works on their site I'm confused why it's not working on mine.
var urlRegex = new RegExp('^(?:(?:../)|/)?(?:w(?:[w`~!$=;-+.^()|{}[]]|(?:%dd))*w?)?(?:/w(?:[w`~!$=;-+.^()|{}[]]|(?:%dd))*w?)*(?:?[^#]+)?(?:#[a-z0-9]w*)?$', 'g');
NOTE:
If you're going to test the regex from their site (using the link above) be sure to change the Regex Engine
dropdown to Client-side Engine
and the Engine
dropdown to Javascript
.