<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <style type="text/css"> div{ background-color:#eee; padding:5px; } span{ background-color:#4fc81f; display:block; padding:5px; } </style> <title></title> </head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <body> <span class="result1"></span> <span class="result2"></span> <div id="test1">background-image: url(../images/background.png)</div> <div id="test2">background-image: url('../images/background.png')</div> <div id="test3">background-image: url("/assets/images/loginlogo.png")</div> <div id="test4">background-image: url(/assets/images/loginlogo.png)</div> <div id="test4">background-image: url(assets/images/loginlogo.png)</div> <script type="text/javascript"> var al= $( "#test3" ).text(); var url=/url\((.*?)\)/.exec(al); purl=url[1].replace('"','').replace("'","").replace('"',"").replace("'",""); $( ".result1" ).html(url[0]); $( ".result2" ).html(purl); </script> </body> </html>