I am trying to write a regex expression for a URL that matches if you include the protocol (https://), and host name (name and extension e.g youtube.com). i have included a regex 101 link below.
Where im struggling is trying to not match simply 'youtube' and also writing the syntax for matching https:// as a group. I cant escape properly for the double forward slash or colon.
https://regex101.com/r/0KUyxu/5
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]|[https:\//])$/gm
It should not match:
youtube
https://youtube
www.youtube
It should however match:
https://youtube.com
youtube.com
www.youtube.com
https://www.youtube.com
Any help would be greatly appreciated, thanks!
[https:\//]But why not specify youtube in the pattern?