const url = "https://alibaba.com?a=1&b=2&c=3#/abc/def?a=2&b=3&c=4" function getParamFromURL(url, key) { //...your code const execStr = new RegExp(`/\?${key}=(.+)\#/`) const result = execStr.exec(url) console.log(result[1][0]) } getParamFromURL(url, 'c')