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
Either put -
at the end or beginning of the character class or use two backslashes to do a regex escape within string
since you are using string you need to use two backslashes for each special characters..
NOTE
Check out this answer on SO which explains when to use single or double backslashes to escape special characters