SOURCE

function searchKey(url, key) {
    const params = url.split('?')[1].split('#')[0].split('&')
    console.log(params)
    // const reg = new RegExp(`(?:&?${key}=)(\w)+`,'g')
    // return params.match(reg)
    const res = [];
    const reg = new RegExp(`^${key}=`)
    params.forEach(str => {
        if(str.search(reg)!==-1) {
            res.push(str.split('=')[1])
        }
    })
    return res
}

const url = 'https://jsrun.net?key=1&key=2#hash'
console.log(searchKey(url,'key'))

const str = 'abc${xyz}home'
const reg = /(?:\$\{)\w+(?:\})/g
console.log(reg.exec(str))
console 命令行工具 X clear

                    
>
console