i need a url regex which validates the url string without http://www.
or https://www.
any ideas?
@:%_\+~#= , to match the domain/sub domain name. In this solution query string parameters are also taken care. If you are not using RegEx , then from the expression replace \\ by \ . Hope this helps.
URL regular expressions can be used to verify if a string has a valid URL format as well as to extract an URL from a string.
A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.
It would probably be a good idea to keep the www
's intact in order to preserve the sub-domain. A regex pattern like this:
^([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+.*)$
would match a URL that is not prefixed by a protocol (http://
,https://
,ftp://
,etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With