Improved regular expression to detect resources