Incase anyone else needs to regex for validating YouTube URLS and extracting YouTube IDs from the same URLs.
[Mainly for my reference, as I forgot when I needed to do it again]
To check if they are valid - create a custom state - then on whatever condition you need to kick it off, say a button …
RegEx for this is: (includes the newer YouTube shorts)
Now after the check to see if its valid you can fire off the extraction which looks like this. And for illustration purposes this is then saving to a state for me to test but you could save to the DB or show it or whatever.
includes YT shorts as well.
Got some reminders from this thread How to extract YouTube IDs with Regex and getting poster images