On Sun, Feb 1, 2015 at 12:45 AM, Frank Millman <[email protected]> wrote:
> Is this a recognised format, and is there a standard way of parsing it? If
> not, I will have to special-case it, but I would prefer to avoid that if
> possible.
Doesn't look "standard" to me in any fashion. You shouldn't need to
special case it though, just
s = re.sub("^[+]0*", "", s)
e.g.,
>>> s = '+00000-21.45'
>>> t = '+0000021.45'
>>> re.sub("^[+]0*", "", s)
'-21.45'
>>> re.sub("^[+]0*", "", t)
'21.45'
That should work on all numbers, not just the weird one. Unless you
have bazillions of numbers, it shouldn't be a performance hit either.
Skip
--
https://mail.python.org/mailman/listinfo/python-list