I want to check if the string is the URL of facebook using java regex.
for eg: facebook.com/username
it should also match if it is with the protocol http or https
http://www.facebook.com/xyz
https://www.facebook.com/xyz
or without protocol also
http://www.facebook.com/xyz
I wouldn’t use regex, create a new URL and use getHost to get the hostname and check if its ok for you. (also can check the other URL information)
If you insist on using regex you can use the following:
Should match any combination of
http/httpswith or withoutwww