I am using a regex to try and validate URL’s. The regex I have works very well but the only issue is that it validates URL’s even if there is no http:// in the front. I want it to only validate if the URL has http:// in the front (even if it doesn’t contain a www right after)
This is the regex I’m using:
((https?)\:\/\/)?([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?([a-z0-9-.]*)\.([a-z]{2,3})(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?
Remove the second
?from the left. It’s acting as a quantifier to make the wholehttpsection optional.