A regular expression to extract Youtube video ID from a link.
/(?<=watch\?v=|/videos/|embed\/|youtu.be\/|\/v\/|watch\?v%3D|%2Fvideos%2F|embed%2F|youtu.be%2F|%2Fv%2F)[^#\&\?\n]*/g
Matches:
- https://www.youtube.com/watch?v=hgoXVDo2JuM
- https://www.youtube.com/embed/hgoXVDo2JuM
- https://www.youtu.be/embed/hgoXVDo2JuM
See Also:
Rate This Regex
User Review
( votes)Expression Flags
Flags | Description |
---|---|
i |
Ignore case sensitive. |
g |
Allows global search. |
m |
Allows multiline search. |