var j = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?\//;
I want to restrict only one / coming at the end of the string. How can I restrict that in the above regular expression?
var j = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?\//;
I want to restrict only one / coming at the end of the string. How can I restrict that in the above regular expression?
After the port-part you should have something like:
((match_part)+?(\/(match_part)+?)?)?
This will allow at least one char in each part, and zero or one part first, if one, then zero or one part more. You have to replace match_part with what you actually want to match, I didnt copy your expression since, for example, the hash (#) isn't valid in the url, just at the end
Please don't tell me you are using regular expressions to validate urls when there's the Uri.TryCreate method.