Javascript 正则表达式检查HTTP(s) URL

function testUrl(url) { 

  let pattern = /^http(s)?:\/\/[\w-]+(\.[\w-]+)+(\:\d+)?(\/\w+)*(\?\w+=.*(\&\w+=.*)*)?$/i;

  return pattern.test(url);

}

posted @ 2022-01-11 22:37  黄燃  阅读(644)  评论(0编辑  收藏  举报