Adam
Adam

Reputation: 415

Regex and Yahoo Pipes: How to replace end of url

Here's the Pipe though you may not need it to answer the question: http://pipes.yahoo.com/pipes/pipe.info?_id=85a288a1517e615b765df9603fd604bd

I am trying to modify all url's as so:

http://mediadownloads.mlb.com/mlbam/2009/08/12/mlbf_6073553_th_3.jpg with
http://mediadownloads.mlb.com/mlbam/2009/08/12/mlbtv_6073553_1m.mp4

The syntax should be something like:

In item.mediaUrl replace f with tv and In item.mediaUrl replace last 8 characters with 1m.mp4

mlbf_(\d+)_.* replaced w/ mlbtv_$1_1m.mp4 

breaks the rss feed though I know I am close

Any idea as to what syntax I need there?

Upvotes: 0

Views: 1767

Answers (2)

Håkon
Håkon

Reputation: 300

I do not know how this yahoo pipes work, but this regex should do it according this site:

Regex:

.*?/([0-9]*)/([0-9]*)/([0-9]*)/mlbf_([0-9]*)_.*

Substitution:

http://mediadownloads.mlb.com/mlbam/$1/$2/$3/mlbtv_$4_1m.mp4

Upvotes: 0

Alan Moore
Alan Moore

Reputation: 75232

Your regex and replacement look okay to me, assuming the regex is being applied only to the URLs. If it were being applied to the surrounding text as well, the .* would tend to consume a lot more than you wanted. See what happens if you change the regex to this:

mlbf_(\d+)_[\w.]+

Upvotes: 1

Related Questions