httpsimgmpitccnupload201702146e8134804caa48d890f73b72443c8d89_thjpg COMMENT头像地址头像地址vue3怎么提取出url
在Vue3中,你可以使用正则表达式来提取出URL。下面是一个示例代码:
// 假设你已经从某个地方获取到了包含URL的字符串
let str = "https://img.mp.itc.cn/upload/20170214/6e8134804caa48d890f73b72443c8d89_th.jpg";
// 使用正则表达式提取URL
let url = str.match(/(http[s]?:\/\/[^\s]+)/g);
// 打印提取到的URL
console.log(url); // 输出:["https://img.mp.itc.cn/upload/20170214/6e8134804caa48d890f73b72443c8d89_th.jpg"]
这段代码中,使用了正则表达式/(http[s]?:\/\/[^\s]+)/g来匹配URL。match方法返回一个数组,其中包含所有匹配的URL。你可以根据你的需要来使用提取到的URL。
原文地址: https://www.cveoy.top/t/topic/h97U 著作权归作者所有。请勿转载和采集!