use strict;
my $str = 'http://www.youtube.com/watch?v=GKnQGP67Xd0
https://www.youtube.com/watch?v=GKnQGP67Xd0
https://www.youtube.com/watch?v=GKnQGP67Xd0
https://www.youtube.com/watch?v=GKnQGP67Xd0
https://vimeo.com/662065137
https://vimeo.com/662065137
https://www.youtube.com/c/riotgamesmusic
https://vimeo.com/662065137
https://youtu.be/aXUCHNaZkWo
https://vimeo.com/662065137
https://vimeo.com/baconbaconbacon
https://www.youtube.com/channel/UCG_wKjFPEpdHf1Q6bTdE2JA
https://player.vimeo.com/video/662065137
última formato corto: http://youtu.be/NLqAF9hrVbY
iframe: http://www.youtube.com/embed/NLqAF9hrVbY
iframe (seguro): https://www.youtube.com/embed/NLqAF9hrVbY
objeto param: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
objeto de incrustación: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
ver: http://www.youtube.com/watch?v=NLqAF9hrVbY
usuarios: http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo
ytscreeningroom: http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I
cualquier cosa vale!: http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/2/PPS-8DMrAn4
cualquier/subdominio/: http://gdata.youtube.com/feeds/api/videos/NLqAF9hrVbY
más params: http://www.youtube.com/watch?v=spDj54kf-vY&feature=g-vrec
la consulta puede tener el punto: http://www.youtube.com/watch?v=spDj54kf-vY&feature=youtu.be';
my $regex = qr/(https?:\/\/)?(www.)?((player.vimeo.com\/video\/[0-9]{9})|((youtube.com|youtu\.be)\/embed\/([\w-]{9,11})))/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html