I'm running the following code on Webkit:
var scriptElements = document.scripts; var scriptUrls = []; // URL matching var regexp = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i; for (var i = 0; i < scriptElements.length; i++) { element = scriptElements[i]; var urls = element.innerHTML.match(regexp); console.log('local', urls); scriptUrls.concat(urls); console.log('global', scriptUrls); } I see non-empty arrays printed after 'local' but the 'global' always stays as an empty array. What's going on?