Currently, a previously answered question left me with this regex i开发者_开发百科n find:
^.+(\?|&)v=([a-zA-Z0-9]+).*$
With this as replace
hxxp://www.youtube.com/v/$1
I want to convert
hxxp://www.youtube.com/?watch="YoutubeID"
to
Youtube.com/v/youtubeID.
The current regex fails under this circumstance.
http://www.youtube.com/watch?v=67-YcLickUA
As it returns
...v=67, instead of the full VideoID.
use strict;
use warnings;
my $string = 'http://www.youtube.com/watch?v=67-YcLickUA';
$string =~ s(.+watch\?v=([0-9a-zA-Z-]+))(Youtube.com/v/$1);
print "$string\n";
This is a very basic replacement, but as I don't know the context etc. you want to use it in it seems good enough for the time being. If you need anything more sophisticated, please let me know.
精彩评论