moved function extractNameMatchingRegex outside load event listener