What is the cleanest way to obtain the numeric prefix of a string in Python?
By \"clean\" I mean simple, short, readable. I couldn\'t care less about performance, a
Another regexp version strips away everything starting with the first non-digit:
import re output = re.sub('\D.*', '', input)