str.replace(/(http:\\/\\/|https:\\/\\/|\[A-Za-z0-9\]+\[\\-\]?\[A-Za-z0-9\]+\\.|\[A-Za-z0-9\]+\\.)((\\w|=|\\?|\\.|\\/|&|-)*)/g, '<a οnclick="alert(\\'$1$2\\')">$1$2</a>');
JS字符串匹配所有网址(二级域名、多级域名)的正则表达式(亲测可用)
最新推荐文章于 2024-09-24 10:50:41 发布
str.replace(/(http:\\/\\/|https:\\/\\/|\[A-Za-z0-9\]+\[\\-\]?\[A-Za-z0-9\]+\\.|\[A-Za-z0-9\]+\\.)((\\w|=|\\?|\\.|\\/|&|-)*)/g, '<a οnclick="alert(\\'$1$2\\')">$1$2</a>');