Regex and Yahoo Pipes: How to replace end of url

时光总嘲笑我的痴心妄想 提交于 2019-12-11 18:16:57

问题


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?


回答1:


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.]+



回答2:


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


来源:https://stackoverflow.com/questions/1275527/regex-and-yahoo-pipes-how-to-replace-end-of-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!