js string to regex

JavaScript
const match = 'some/path/123'.match(/\/(\d+)/)
const id = match[1] // '123'const regex = new RegExp('https:\\/\\/\\w*\\.\\w*.*', 'g');// Tests website Regular Expression against document.location (current page url)
if (/^https\:\/\/example\.com\/$/.exec(document.location)){
	console.log("Look mam, I can regex!");
}
Source

Also in JavaScript: