I am trying to get youtube video id from a different set of Youtube URL'S. I wrote the below regex for getting video id from a set of youtube URLs. I wrote this in python.
But,
The problem is can we implement the same logic in javascript as well? Since I am quite new to javascript, I need help with it.
if data.startswith('https://') or data.startswith('http://'):
v = re.search("(?:\/|%3D|v=|vi=)([0-9A-z-_]{11})(?:[%#?&]|$)", data)
data="https://www.youtube.com/watch?v="+v.group(1)
*The above code is in python, data is a Youtube URL. (I have tried multiple times, but didn't work for me, Hence here.)