refactoring some of the error handling to be less severe and fixed a bug with the regex
tweak matching to reset lastIndex and fail hard if there is a string with no matching configuration