I have the following regex to check for relative url there is a function that checks the url and returns true if its ok, the following works:
MyCustomPage.aspx?name=John&last=smith&type=Person
But the follwing when i have more than two words in the last name with a space separating them returns false
MyCustomPage.aspx?name=John&last=smith+connors&type=Person
See the +connors, this would not evaluate… but if i remove the check.. it goes through fine..
This is the regex
Regex IsRelative = new Regex(@"^([a-zA-Z0-9]+)+\.[a-zA-Z/]*(((\?)([a-zA-Z]*=\w*)){1}((&)([a-zA-Z]*=\w*))*)?$");
in my function i check if the url is valid based on that regex
IsRelative(MyUrl)
I need it to let it pass if there is a space in there but i am not sure how.. anyhelp would be appreciated.
You should allow plus signs (+) as the argument values:
Here, I changed
\winto[\w\+], where the regex checks for argument values. With this change you will be allowing urls that have plus signs (+) at the right of the equal sign (=) of each argument.