👌

JavaScriptのURLとマッチする正規表現

2022/05/25に公開
const pattern = /^https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+$/
const result1 = pattern.test('https://zenn.dev/purratto?page=1')
console.log(result1) // true

const result2 = pattern.test('zenn')
console.log(result2) // false

Discussion