I want to validate a URL using regular expression. Following are my conditions to validate the URL:
- Scheme is optional
- Subdomains should be allowed
- Port number should be allowed
- Path should be allowed.
I was trying the following pattern:
((http|https)://)?([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
But I am not getting the desired results. Even an invalid URL like '*.example.com' is getting matched.
What is wrong with it?