This pattern aims to match (testing only) all Youtube's and Vimeo's URL variants.
^(?:https?:)?(?:(?:\/\/(?:(?:www\.)?(?:youtube\.com)|youtu\.be)\/.*?(?:watch\?v=|embed\/)?)?(?:[\w-]{11}(?![\w-]))|(?:\/\/vimeo\.com\/)?[\d]{9}(?![\w])).*$
This pattern matches Youtube only URLs:
^((https?:)?(?:(?:\/\/((?:www\.)?youtube\.com|youtu\.be)\/.*?(?:watch\?v=|embed\/)?)))?([\w-]{11})
- group 2: stores the protocol
- group 3: stores the domain