const patt = /url\((.*)\)/g const str = `h1{ color: red; background: url(./assets/n1.png); } h2{ color: red; background: url(./assets/n2.png); } ` while ((result = patt.exec(str)) != null) { console.log(result[1]) }