根据给定的重复文本获取正则表达式的一部分

时间:2016-08-03 08:38:57

标签: regex regex-greedy

我有正则表达式,没有得到理想的结果:

(.*)"title":"(.+?)"(.*)"stream_url":"(.+?)"(.*)*

如何构建以上值的正则表达式:

{ “ID”: “334”,"title":"Al Kahera Wal Nas", “追赶”:假, “说明”: “”, “epg_channel_id”: “196”, “genre_id”: “20”, “pin_required” :假的, “试”:真实的, “SERVER_ID”: “8”, “流派”: “埃及”, “标志”:“https://s3-eu-west-1.amazonaws.com/static.prod/存储/ 26 /内容/ 56440c5f-8504-4d85-bcf8-5984ac1f2e8b-AlKaheraWalNas.jpg “"stream_url":"http:\/\/lv001.cdn03.greek.zaaptv.com:80\/live\/m3u8\/Alkahera.m3u8?__token__=ip=182.186.64.249~exp=1470381422~acl=\/live\/m3u8\/Alkahera.m3u8*~hmac=7d1cabf155247a1c3e3ce03d19dcdeeea484bb86f35680d9ebf27573d114dd90", ”stream_m3u8_url“:” http://lv001.cdn03.greek.zaaptv.com:80/live/ ?M3U8 / Alkahera.m3u8的令牌 = IP = 182.186.64.249〜EXP = 1470381422〜ACL = /活/ M3U8 / Alkahera.m3u8 *〜HMAC = 7d1cabf155247a1c3e3ce03d19dcdeeea484bb86f35680d9ebf27573d114dd90" , “dvr_url”: “”}} ,{ “信道”:{ “ID”: “380”,"title":"Al Kahera Wal Nas +2", “追赶”:假, “说明”: “”, “epg_channel_id”: “197”, “genre_id”: “20”, “pin_required”:假的, “试”:真实的, “SERVER_ID”: “8”, “流派”: “埃及”, “标志”:“https://s3-eu-west-1.amazonaws.com/static .prod /存储/ 26 /内容/ 564e6db3-10bc-43ca-8e53-2ce9ac1f2e8b-AlKaheraWalNasplus2.jpg “"stream_url":"http:\/\/lv001.cdn03.greek.zaaptv.com:80\/live\/m3u8\/Alkahera2.m3u8?__token__=ip=182.186.64.249~exp=1470381422~acl=\/live\/m3u8\/Alkahera2.m3u8*~hmac=b4f1d4406c973e8d5806ec88da56c035d912ec370ff84d9513a7f49218eacd06", ”stream_m3u8_url“:” http://lv001.cdn03.greek.zaaptv.com:80 /live/m3u8/Alkahera2.m3u8?token=ip=182.186.64.249~exp=1470381422~ac升= /活/ M3U8 / Alkahera2.m3u8 *〜HMAC = b4f1d4406c973e8d5806ec88da56c035d912ec370ff84d9513a7f49218eacd06" , “dvr_url”: “”}},

2 个答案:

答案 0 :(得分:1)

这对你有用吗?

"title":"([^"]+?)"(.*?)|"stream_url":"([^"]+?)"

它基于baddger964的答案,但修改后放置|以便它将分别匹配每个实例

答案 1 :(得分:0)

试试这个:

"title":"([^"]+?)"(.*?)"stream_url":"([^"]+?)"
带有全局标志的

/"title":"([^"]+?)"(.*?)"stream_url":"([^"]+?)"/g