support optional pattern match in matchRest