Handle exception when user defined regular expression is invalid.