提问人:vitinnn46 提问时间:11/12/2023 更新时间:11/12/2023 访问量:37
正则表达式,用于删除除记事本++或 regex101.com 链接之外的所有内容
Regular expression to remove everything except links for notepad++ or regex101.com
问:
所以我已经尝试了多次,但无济于事。
我有一个代码,我需要删除除链接之外的所有内容。域可以是任何域,http 或 https
/**/
jQuery(function($){
playerInit( 11403, 'Убийца Богов', 'json', [{"id":"0","title":" 176","url":"https://ii-z.ru/11403/176.mp3","error":0,"duration":909,"duration_min":"15:09"},{"id":"1","title":" 177","url":"https://ii-z.ru/11403/177.mp3","error":0,"duration":850,"duration_min":"14:10"},{"id":"2","title":" 178","url":"https://ii-z.ru/11403/178.mp3","error":0,"duration":800,"duration_min":"13:20"},{"id":"3","title":" 179","url":"https://ii-z.ru/11403/179.mp3","error":0,"duration":834,"duration_min":"13:54"},{"id":"4","title":" 180","url":"https://ii-z.ru/11403/180.mp3","error":0,"duration":898,"duration_min":"14:58"},{"id":"5","title":" 181","url":"https://ii-z.ru/11403/181.mp3","error":0,"duration":777,"duration_min":"12:57"},{"id":"6","title":" 182","url":"https://ii-z.ru/11403/182.mp3","error":0,"duration":832,"duration_min":"13:52"},{"id":"7","title":" 183","url":"https://ii-z.ru/11403/183.mp3","error":0,"duration":827,"duration_min":"13:47"},{"id":"8","title":" 184","url":"https://ii-z.ru/11403/184.mp3","error":0,"duration":837,"duration_min":"13:57"},{"id":"9","title":" 185","url":"https://ii-z.ru/11403/185.mp3","error":0,"duration":809,"duration_min":"13:29"},{"id":"10","title":" 186","url":"https://ii-z.ru/11403/186.mp3","error":0,"duration":853,"duration_min":"14:13"},{"id":"11","title":" 187","url":"https://ii-z.ru/11403/187.mp3","error":0,"duration":860,"duration_min":"14:20"},{"id":"12","title":" 188","url":"https://ii-z.ru/11403/188.mp3","error":0,"duration":881,"duration_min":"14:41"},{"id":"13","title":" 189","url":"https://ii-z.ru/11403/189.mp3","error":0,"duration":815,"duration_min":"13:35"},{"id":"14","title":" 190","url":"https://ii-z.ru/11403/190.mp3","error":0,"duration":720,"duration_min":"12:00"},{"id":"15","title":" 191","url":"https://ii-z.ru/11403/191.mp3","error":0,"duration":757,"duration_min":"12:37"},{"id":"16","title":" 192","url":"https://ii-z.ru/11403/192.mp3","error":0,"duration":873,"duration_min":"14:33"},{"id":"17","title":" 193","url":"https://ii-z.ru/11403/193.mp3","error":0,"duration":801,"duration_min":"13:21"},{"id":"18","title":" 194","url":"https://ii-z.ru/11403/194.mp3","error":0,"duration":902,"duration_min":"15:02"},{"id":"19","title":" 195","url":"https://ii-z.ru/11403/195.mp3","error":0,"duration":830,"duration_min":"13:50"},{"id":"20","title":" 196","url":"https://ii-z.ru/11403/196.mp3","error":0,"duration":820,"duration_min":"13:40"},{"id":"21","title":" 197","url":"https://ii-z.ru/11403/197.mp3","error":0,"duration":968,"duration_min":"16:08"},{"id":"22","title":" 198","url":"https://ii-z.ru/11403/198.mp3","error":0,"duration":790,"duration_min":"13:10"},{"id":"23","title":" 199","url":"https://ii-z.ru/11403/199.mp3","error":0,"duration":790,"duration_min":"13:10"}], 'https://audiokniga.one/uploads/posts/2023-11/1699047567_1-1.webp');
});
/**/
最后,我需要获取一个链接列表,每个链接都来自一个新行
https://ii-z.ru/11403/177.mp3
https://ii-z.ru/11403/178.mp3
https://ii-z.ru/11403/179.mp3
我希望有人能帮助我。
我有代码可以突出显示所有链接以及标志,但我不知道如何保存它们并剪掉标志
https?:\/\/.*?[\s+"]
答:
1赞
Toto
11/12/2023
#1
注意:将光标放在文件的最开头
- Ctrl+H
- 查找内容:
"url":"([^"]+)"|.
- 替换为:
(?1$1\n)
- SELECT 正则表达式
- 取消勾选
. matches newline
- Replace all
解释:
"url":" # literally
([^"]+) # group 1, 1 or more any character that is not a double quote
" # double quote
| # OR
. # any character
更换:
(?1 # if group 1 exists
$1 # print it
\n # line feed, you can use \r\n for Windows
) # endif
截图(前):
截图(后):
评论
0赞
vitinnn46
11/12/2023
这正是我一直在寻找的,谢谢!
评论
grep -oE ' https?:\/\/[^\s+"]+' my-file.html