Re: Inserting '-' character in front of all numbers in a string
- From: Michael Bentley <michael@xxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Mar 2007 18:17:23 -0500
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())
;-)
.
- References:
- Inserting '-' character in front of all numbers in a string
- From: kevinliu23
- Re: Inserting '-' character in front of all numbers in a string
- From: Michael Bentley
- Re: Inserting '-' character in front of all numbers in a string
- From: Paul McGuire
- Inserting '-' character in front of all numbers in a string
- Prev by Date: Re: Newbie Question (real-time communication between apps: audio, 3d, PD, Blender)
- Next by Date: Re: New to Python - Easy way to open a text file
- Previous by thread: Re: Inserting '-' character in front of all numbers in a string
- Next by thread: New to Python - Easy way to open a text file
- Index(es):