Regular Expressions 101

youtube iframe embed code src video id and params

Open Workspace
  • JavaScript
  • Match
0

Regular Expression

/
<iframe[\s\w="\/]*src="(?<src>(?:https*:\/\/)?www\.youtube(?:-nocookie)?\.com\/embed\/(?<vid>[-a-zA-Z0-9@:;%_+.~#&=]+)\??(?<params>[-a-zA-Z0-9@:;%_+.~#?&\/=]*))"[^>]*>(?:<\/iframe>)?$
/
gm

Description

Matches full src url and individual video id and params in a YouTube iframe embed tag.

Submitted by Robert Klein Kromhof