[Tutor] Remove a number from a string
alan.gauld at freenet.co.uk
Tue Aug 23 22:47:40 CEST 2005
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the
> I can think of a few ways but whats the cleanest way to do it?
If you know they are always a contiguous string themn a simple split()
call will do it:
s = ' '.join(s.split()[1:])
If the numbes may form a more complex pattern then a regex would be
Use the regex to find the end index and use a slice around the index.
More information about the Tutor