let url = "http://localhost:3000/#room=d20a6268d8970c548f87,5ThfXj5qKTlrs1RdGriNVQ?a=47472717032&version=1"; const RE_COLLAB_LINK = /^#room=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)/; let hash = new URL(url).hash; console.log(RE_COLLAB_LINK.test(hash)); const match = hash.match(RE_COLLAB_LINK); console.log(match[1]); console.log(match[2].length);