I have a string of the form "foo-bar-1.23-4", and I need to split at the first hypen followed by a numeral, such that the result is ['foo-bar', '1.23-4']. I've tried the following:
>>> re.split('-\d', 'foo-bar-1.23-4', 1)
['foo-bar', '.23-4']
and
>>> re.split('-(\d)', 'foo-bar-1.23-4', 1)
['foo-bar', '1', '.23-4']
with suboptimal results. Is there a one-liner that will get me what I want, without having to munge the delimiter with the last element?