Reputation: 91
All,
I am new to REGEX world...
I know that there are lot of regex avail for validating the common URL with http in it.
But I am looking for a regex to validate the URL in the following formats(without HTTP/HTTPS):
in case if the URL contains only,
I should throw an error to the user.
any help would be highly appreciated...
Thanks Raj
Upvotes: 0
Views: 1797
Reputation: 425278
This regex will pass your first set, but not match the second set:
^www\.example\.(com|co.xx)(/.*)?$
In English, this regex requires:
www.example.
com
or co.xx
/
then anythingYou could be more prescriptive about what can follow the optional slash by replacing (/.*)
with (/(user|buy|sell)\?.*)
etc
Upvotes: 0