[COOK-4723] Package resource enhancements

The regular expression we match against is based on user input and it could even be a normal package name which upsets the regular expression compiler. If it cannot be compiled, the SyntaxError is raised and should be handled.

The NoMethodError effectively means that there was no match, in which case, the exception handler ensures ‘nil’ is assigned.

The exception handler takes care of both scenarios.