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

2007-04-03 Thread Jorgen Grahn
On 30 Mar 2007 08:38:27 -0700, kevinliu23 <[EMAIL PROTECTED]> wrote: > Hey guys, > > I want to be able to insert a '-' character in front of all numeric > values in a string. I want to insert the '-' character to use in > conjunction with the getopt.getopt() function. ... > "2a 3ab" into "-2a -3ab"

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

2007-03-30 Thread Michael Bentley
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()) ;-) -- http://mail.pytho

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

2007-03-30 Thread Michael Bentley
On Mar 30, 2007, at 4:41 PM, Paul McGuire wrote: > On Mar 30, 2:09 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: >> On Mar 30, 2007, at 10:38 AM, kevinliu23 wrote: >> >> >> >> >> >>> I want to be able to insert a '-' character in front of all numeric >>> values in a string. I want to insert the

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

2007-03-30 Thread John Nagle
Paul McGuire wrote: > On Mar 30, 2:09 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: > >>On Mar 30, 2007, at 10:38 AM, kevinliu23 wrote: >> >> >> >> >> >> >>>I want to be able to insert a '-' character in front of all numeric >>>values in a string. I want to insert the '-' character to use in >>>c

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

2007-03-30 Thread Paul McGuire
On Mar 30, 2:09 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: > On Mar 30, 2007, at 10:38 AM, kevinliu23 wrote: > > > > > > > I want to be able to insert a '-' character in front of all numeric > > values in a string. I want to insert the '-' character to use in > > conjunction with the getopt.get

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

2007-03-30 Thread Michael Bentley
On Mar 30, 2007, at 10:38 AM, kevinliu23 wrote: > I want to be able to insert a '-' character in front of all numeric > values in a string. I want to insert the '-' character to use in > conjunction with the getopt.getopt() function. > > Rigt now, I'm implementing a menu system where users will b

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

2007-03-30 Thread kevinliu23
Hey guys, thanks for the quick replies. I'm looking for something more generic than adding it to "2a 3ab". For example, under the menu option 2, there can be upwards of 8 other suboptions. I'll see what's suggested here and post back if I run into more problems. Thanks guys! -- http://mail.python

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

2007-03-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, kevinliu23 wrote: > "2a 3ab" into "-2a -3ab". In [8]: '-' + ' -'.join('2a 3ab 4xy'.split()) Out[8]: '-2a -3ab -4xy' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

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

2007-03-30 Thread Larry Bates
kevinliu23 wrote: > Hey guys, > > I want to be able to insert a '-' character in front of all numeric > values in a string. I want to insert the '-' character to use in > conjunction with the getopt.getopt() function. > > Rigt now, I'm implementing a menu system where users will be able to > sele

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

2007-03-30 Thread kyosohma
On Mar 30, 10:38 am, "kevinliu23" <[EMAIL PROTECTED]> wrote: > Hey guys, > > I want to be able to insert a '-' character in front of all numeric > values in a string. I want to insert the '-' character to use in > conjunction with the getopt.getopt() function. > > Rigt now, I'm implementing a menu

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

2007-03-30 Thread kevinliu23
Hey guys, I want to be able to insert a '-' character in front of all numeric values in a string. I want to insert the '-' character to use in conjunction with the getopt.getopt() function. Rigt now, I'm implementing a menu system where users will be able to select a set of options like "2a 3ab"