Catch exception if regex has an error