如何正则匹配第二个https?
https://hls.kuaibofang.com/url=https://gng.hwusting.com/123456/aaveU3B3jM/index.m3u8
期望结果https://gng.hwusting.com/123456/aaveU3B3jM/index.m3u8
回答:
url=(.*)\"
匹配后应该是url=https://gng.hwusting.com/1234"
你在替换一下字符串就行了
回答:
str.match(/(^|&)url=([^&]*)(&|$)/)
这个正则兼容性更强,可以兼容你的query里有多个参数的情况
回答:
const str = 'https://hls.kuaibofang.com/url=https://gng.hwusting.com/123456/aaveU3B3jM/index.m3u8'// => https://gng.hwusting.com/123456/aaveU3B3jM/index.m3u8
const data = str.replace(/^.*?=(.*)$/, '$1')
回答:
如下图:
点击查看匹配结果
代码
# coding=utf8import re
regex = r"(?<=\burl=).+"
test_str = "https://hls.kuaibofang.com/url=https://gng.hwusting.com/123456/aaveU3B3jM/index.m3u8"
matches = re.search(regex, test_str, re.MULTILINE)
if matches:
print ("在{start}-{end}处匹配成功: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
以上是 如何正则匹配第二个https? 的全部内容, 来源链接: utcz.com/p/938705.html