Catch error with regex