The problem with regex_findall
is that if it doesn’t find a match for its pattern, it fails with an error. Ideally it should return None or something to indicate “failed to find a match”. Basically, for this application, it works no better than split
failing if the value has no comma.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information refer to guideline 21 in the FAQ.