用正则将API返回的数据去除标签并整理

一、API返回的数据:
在这里插入图片描述

二、用到的正则表达式

regex = /((ht|f)tps?):\/\/([\w\-]+(\.[\w\-]+)*\/)*[\w\-]+(\.[\w\-]+)*\/?(\?([\w\-\.,@?^=%&:\/~\+#]*)+)?/g

三、整理格式后
在这里插入图片描述

四、使用方法

let regex = /((ht|f)tps?):\/\/([\w\-]+(\.[\w\-]+)*\/)*[\w\-]+(\.[\w\-]+)*\/?(\?([\w\-\.,@?^=%&:\/~\+#]*)+)?/g

 Images = str.match(regex)

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/koufulong/article/details/88169730
今日推荐