我需要阻止/验证字符串中的缩短 URL。下面的字符串包含缩短 URL 如何在 string 中阻止/验证它。嗨#first_name# 我是来自 Novato Cleaners 的 Mondi。我可以帮个忙吗?我们的谷歌https://bit.ly需要评论。你能提供一份吗?谢谢
2 回答
莫回无
TA贡献1865条经验 获得超7个赞
因此,为此您需要执行以下步骤:
1-从字符串中提取所有网址。
3- 当你有时originalUrl
,只需检查是否url
!=originalUrl
那么它是一个缩短的 url。
拉莫斯之舞
TA贡献1820条经验 获得超10个赞
使用正则表达式查找您的字符串中是否有 URL,如果他们只是替换它您在该空间上需要的内容
/(https?://[^\s]+)/g
var string = "Hi Vignesh This is Mondi from Novato Cleaners. May I ask for a favor ? Our google https://bit.ly requires reviews. Could you provide one ?Thank you";
var protomatch = /(https?:\/\/[^\s]+)/g;
var b = string.replace(protomatch, '');
console.log(b)
添加回答
举报
0/150
提交
取消