Just a specific python question here. Let's say that I have a string like:
s = 'John 000117'
I want the output to be:
s_output = 'John 117'
How would I go about doing this? In general, I need to assume that the input string is a combination of alphabetical characters and numerics, and that the numeric parts of the strings may or may not have 0's padded in front of them. I also want to preserve all parts of the input string that are not numeric, as I am only touching the numeric parts. Adding a lot of spaces is ok because I can just use another regular expression to clean any excess spaces up.
My Initial Attempt
Initially, I mistakenly did the regular expression subtitution:
re.sub('^0*', ' ', s)
because I thought this would replace 0 or more occurrences of the 0's at the beginning of my string with a space, but I realized that this doesn't locate the substring that has leading zeros (this simply adds a space to the beginning of my string s). My question, more specifically, is, how do I locate substrings that have numerics padded with 0's and then use a regular expression like the one above?
Any help is appreciated, especially if it's something that can use a regular expression (I would prefer not to split or substring but I will if that's the only way).