Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Currently, a previously answered question left me with this regex in 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.

like image 640
TheBetterJORT Avatar asked Dec 04 '25 06:12

TheBetterJORT


1 Answers

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.

like image 161
canavanin Avatar answered Dec 06 '25 01:12

canavanin