var str = "url(../images/kk.png)"; var pattern = /\w+\.\w{3}/g; console.log(str.match(pattern)[0]); // 'kk.png'