Re: Inserting '-' character in front of all numbers in a string




On Mar 30, 2007, at 5:42 PM, Michael Bentley wrote:
for i in yourstring.split():
if i[0].isdigit():
yourstring = yourstring.replace(i, '-%s' % (i,), 1)

*OR*

yourstring ' '.join(x[0].isdigit() and '-%s' % x or x for x in yourstring.split())

;-)


.