我正在使用JavaScript进行正则表达式,来自youtube的回复给了我这个:
fexp=906719,913403,910210&url_encoded_fmt_stream_map=url=http://o-o.preferred.comcast-lga1.v6.lscache1.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=37&ip=74.0.0.0&signature=D2B45EFC1903EAA5DC3B9A247CF463D74E99E73C.13DD65B9096D2D4AB3A18F52CBFFD39CBDEB78F4&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=hd1080&fallback_host=tc.v6.cache1.c.youtube.com&type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&itag=37,url=http://o-o.preferred.comcast-lga1.v19.lscache6.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=45&ip=74.0.0.0&signature=2FF46F4FE06E23E50536A58FF82312065AF5469D.BE984668668AA0A29F1D124128D1B195EAD15EE0&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=hd720&fallback_host=tc.v19.cache6.c.youtube.com&type=video/webm;+codecs="vp8.0,+vorbis"&itag=45,url=http://o-o.preferred.comcast-lga1.v6.lscache1.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=22&ip=74.0.0.0&signature=9C8EF636588F58316381D2860E4E51EBA02AE7F2.94D082F7E7825CEF859869532F827C7625A6DBF4&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=hd720&fallback_host=tc.v6.cache1.c.youtube.com&type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&itag=22,itag=84&url=http://o-o.preferred.comcast-lga1.v8.lscache3.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=84&ip=74.0.0.0&signature=A15A2D7498577BEE5792CD49859DB11840BD5C1B.23A713594752E80B094E91BB769FFC392A9CD0C0&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&fallback_host=tc.v8.cache3.c.youtube.com&stereo3d=1&quality=hd720,url=http://o-o.preferred.comcast-lga1.v19.lscache7.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=44&ip=74.0.0.0&signature=CD8C7397913A2DBE3319976C64E47F576A786046.D7D5E38EC6A8EDE83B2C0AEDF9A66BABCCAF2A92&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=large&fallback_host=tc.v19.cache7.c.youtube.com&type=video/webm;+codecs="vp8.0,+vorbis"&itag=44,url=http://o-o.preferred.comcast-lga1.v22.lscache1.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=35&ip=74.0.0.0&burst=40&sver=3&signature=A304211CE7179E72E9718B73B656519592042B7E.3ED4B5D95717F11EB9413534431D80C15620C521&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=large&fallback_host=tc.v22.cache1.c.youtube.com&type=video/x-flv&itag=35,url=http://o-o.preferred.comcast-lga1.v5.lscache8.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=43&ip=74.0.0.0&signature=4DF90C75CE0C5A2EDD6CAAD68A5E3E8B381DA3DF.4EF184DD4C8B1BAD435C42268F51B1B1DCBCD54A&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=medium&fallback_host=tc.v5.cache8.c.youtube.com&type=video/webm;+codecs="vp8.0,+vorbis"&itag=43,url=http://o-o.preferred.comcast-lga1.v6.lscache6.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=34&ip=74.0.0.0&burst=40&sver=3&signature=1FE1F3A37C8762F891193E6C9523AA0C33EFA862.10C967EBDECA4DAE5C1D9220E4B693EF32A01F8F&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=medium&fallback_host=tc.v6.cache6.c.youtube.com&type=video/x-flv&itag=34,url=http://o-o.preferred.comcast-lga1.v9.lscache6.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=18&ip=74.0.0.0&signature=3A833C0FDD1669AA9E0198D55A98C790013CEB72.D5FCEF40C6EFA1B43F07893B4FA1A34256182393&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=medium&fallback_host=tc.v9.cache6.c.youtube.com&type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"&itag=18,itag=82&url=http://o-o.preferred.comcast-lga1.v11.lscache8.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=82&ip=74.0.0.0&burst=40&sver=3&signature=6B1A8645AE569BA39C2417AEAA8AB2E7DC14B397.A2D58860B5632B304B4865EC9A5D46C45EF24B48&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"&fallback_host=tc.v11.cache8.c.youtube.com&stereo3d=1&quality=medium,url=http://o-o.preferred.comcast-lga1.v19.lscache2.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=5&ip=74.0.0.0&burst=40&sver=3&signature=2ED86C29257347935C1B2541C9E38DA192835059.B6952FB561DAA0650639B344057FF14D2033E25B&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=small&fallback_host=tc.v19.cache2.c.youtube.com&type=video/x-flv&itag=5&allow_embed=1&vq=auto&allow_ratings=1&keywords=Big+Buck+Bunny,Outtakes,Big+Buck+Bunny+HD,kampac,MRKAMPAC,1080P,Full+HD,KAMPACX264&track_embed=0&view_count=49660&fmt_list=37/1920x1080/9/0/115,45/1280x720/99/0/0,22/1280x720/9/0/115,84/1280x720/9/0/115,44/854x480/99/0/0,35/854x480/9/0/115,43/640x360/99/0/0,34/640x360/9/0/115,18/640x360/9/0/115,82/640x360/9/0/115,5/320x240/7/0/0&author=MRKAMPAC&muted=0&length_seconds=53&iurlmaxres=http://i1.ytimg.com/vi/HIrMIeN5ttE/maxresdefault.jpg&has_cc=False&tmi=1&ftoken=&iurlsd=http://i1.ytimg.com/vi/HIrMIeN5ttE/sddefault.jpg&status=ok&watermark=,http://s.ytimg.com/yt/img/watermark/youtube_watermark-vflHX6b6E.png,http://s.ytimg.com/yt/img/watermark/youtube_hd_watermark-vflAzLcD6.png×tamp=1321471612&plid=AASx3xYRjlOTsE2S&endscreen_module=http://s.ytimg.com/yt/swfbin/endscreen-vflzGEKEt.swf&hl=en_US&no_get_video_log=1&avg_rating=4.87704918033&title=Big+Buck+Bunny+-+Outtakes+(Full+HD)&sw=0.1&token=vjVQa1PpcFMPhJwCJ7tX2LCxuy1YvwpUXkOLxPQjPtU=&thumbnail_url=http://i1.ytimg.com/vi/HIrMIeN5ttE/default.jpg&video_id=HIrMIeN5ttE
并希望获取url = AND之间的内容;这将导致4项:
等
答案 0 :(得分:1)
我建议使用以下正则表达式:
/url\=([^;]+);/
要匹配多次执行正则表达式所需的所有url=
字符串(使用g
开关):
function getUrls(url) {
var re = /url\=([^;]+);/g,
match, urls = new Array(),
i = 0;
while (match = re.exec(url)) {
urls[i++] = match[1];
}
return urls;
}
var urls = getUrls('fexp=906719,913403,910210&url_encoded_fmt_stream_map=url=http://o-o.preferred.comcast-lga1.v6.lscache1.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=37&ip=74.0.0.0&signature=D2B45EFC1903EAA5DC3B9A247CF463D74E99E73C.13DD65B9096D2D4AB3A18F52CBFFD39CBDEB78F4&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=hd1080&fallback_host=tc.v6.cache1.c.youtube.com&type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&itag=37,url=http://o-o.preferred.comcast-lga1.v19.lscache6.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=45&ip=74.0.0.0&signature=2FF46F4FE06E23E50536A58FF82312065AF5469D.BE984668668AA0A29F1D124128D1B195EAD15EE0&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=hd720&fallback_host=tc.v19.cache6.c.youtube.com&type=video/webm;+codecs="vp8.0,+vorbis"&itag=45,url=http://o-o.preferred.comcast-lga1.v6.lscache1.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=22&ip=74.0.0.0&signature=9C8EF636588F58316381D2860E4E51EBA02AE7F2.94D082F7E7825CEF859869532F827C7625A6DBF4&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=hd720&fallback_host=tc.v6.cache1.c.youtube.com&type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&itag=22,itag=84&url=http://o-o.preferred.comcast-lga1.v8.lscache3.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=84&ip=74.0.0.0&signature=A15A2D7498577BEE5792CD49859DB11840BD5C1B.23A713594752E80B094E91BB769FFC392A9CD0C0&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&fallback_host=tc.v8.cache3.c.youtube.com&stereo3d=1&quality=hd720,url=http://o-o.preferred.comcast-lga1.v19.lscache7.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=44&ip=74.0.0.0&signature=CD8C7397913A2DBE3319976C64E47F576A786046.D7D5E38EC6A8EDE83B2C0AEDF9A66BABCCAF2A92&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=large&fallback_host=tc.v19.cache7.c.youtube.com&type=video/webm;+codecs="vp8.0,+vorbis"&itag=44,url=http://o-o.preferred.comcast-lga1.v22.lscache1.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=35&ip=74.0.0.0&burst=40&sver=3&signature=A304211CE7179E72E9718B73B656519592042B7E.3ED4B5D95717F11EB9413534431D80C15620C521&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=large&fallback_host=tc.v22.cache1.c.youtube.com&type=video/x-flv&itag=35,url=http://o-o.preferred.comcast-lga1.v5.lscache8.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=43&ip=74.0.0.0&signature=4DF90C75CE0C5A2EDD6CAAD68A5E3E8B381DA3DF.4EF184DD4C8B1BAD435C42268F51B1B1DCBCD54A&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=medium&fallback_host=tc.v5.cache8.c.youtube.com&type=video/webm;+codecs="vp8.0,+vorbis"&itag=43,url=http://o-o.preferred.comcast-lga1.v6.lscache6.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=34&ip=74.0.0.0&burst=40&sver=3&signature=1FE1F3A37C8762F891193E6C9523AA0C33EFA862.10C967EBDECA4DAE5C1D9220E4B693EF32A01F8F&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=medium&fallback_host=tc.v6.cache6.c.youtube.com&type=video/x-flv&itag=34,url=http://o-o.preferred.comcast-lga1.v9.lscache6.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,ratebypass,cp&fexp=906719,913403,910210&itag=18&ip=74.0.0.0&signature=3A833C0FDD1669AA9E0198D55A98C790013CEB72.D5FCEF40C6EFA1B43F07893B4FA1A34256182393&sver=3&ratebypass=yes&source=youtube&expire=1321495200&key=yt1&ipbits=8&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=medium&fallback_host=tc.v9.cache6.c.youtube.com&type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"&itag=18,itag=82&url=http://o-o.preferred.comcast-lga1.v11.lscache8.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=82&ip=74.0.0.0&burst=40&sver=3&signature=6B1A8645AE569BA39C2417AEAA8AB2E7DC14B397.A2D58860B5632B304B4865EC9A5D46C45EF24B48&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"&fallback_host=tc.v11.cache8.c.youtube.com&stereo3d=1&quality=medium,url=http://o-o.preferred.comcast-lga1.v19.lscache2.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,source,algorithm,burst,factor,cp&fexp=906719,913403,910210&algorithm=throttle-factor&itag=5&ip=74.0.0.0&burst=40&sver=3&signature=2ED86C29257347935C1B2541C9E38DA192835059.B6952FB561DAA0650639B344057FF14D2033E25B&source=youtube&expire=1321495200&key=yt1&ipbits=8&factor=1.25&cp=U0hRRlRUU19FSkNOMV9MTldDOmVlTnlfd3VDcmM2&id=1c8acc21e379b6d1&quality=small&fallback_host=tc.v19.cache2.c.youtube.com&type=video/x-flv&itag=5&allow_embed=1&vq=auto&allow_ratings=1&keywords=Big+Buck+Bunny,Outtakes,Big+Buck+Bunny+HD,kampac,MRKAMPAC,1080P,Full+HD,KAMPACX264&track_embed=0&view_count=49660&fmt_list=37/1920x1080/9/0/115,45/1280x720/99/0/0,22/1280x720/9/0/115,84/1280x720/9/0/115,44/854x480/99/0/0,35/854x480/9/0/115,43/640x360/99/0/0,34/640x360/9/0/115,18/640x360/9/0/115,82/640x360/9/0/115,5/320x240/7/0/0&author=MRKAMPAC&muted=0&length_seconds=53&iurlmaxres=http://i1.ytimg.com/vi/HIrMIeN5ttE/maxresdefault.jpg&has_cc=False&tmi=1&ftoken=&iurlsd=http://i1.ytimg.com/vi/HIrMIeN5ttE/sddefault.jpg&status=ok&watermark=,http://s.ytimg.com/yt/img/watermark/youtube_watermark-vflHX6b6E.png,http://s.ytimg.com/yt/img/watermark/youtube_hd_watermark-vflAzLcD6.png×tamp=1321471612&plid=AASx3xYRjlOTsE2S&endscreen_module=http://s.ytimg.com/yt/swfbin/endscreen-vflzGEKEt.swf&hl=en_US&no_get_video_log=1&avg_rating=4.87704918033&title=Big+Buck+Bunny+-+Outtakes+(Full+HD)&sw=0.1&token=vjVQa1PpcFMPhJwCJ7tX2LCxuy1YvwpUXkOLxPQjPtU=&thumbnail_url=http://i1.ytimg.com/vi/HIrMIeN5ttE/default.jpg&video_id=HIrMIeN5ttE');