开发者

Replace Youtube URL in Yahoo Pipes with /v from watch?v=

开发者 https://www.devze.com 2023-02-02 02:24 出处:网络
Currently, a previously answered question left me with this regex i开发者_开发百科n find: ^.+(\\?|&)v=([a-zA-Z0-9]+).*$

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消