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

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Mar 30 12:42:03 EDT 2007


In <1175269107.769945.241500 at r56g2000hsd.googlegroups.com>, kevinliu23
wrote:

> "2a 3ab" into "-2a -3ab".

In [8]: '-' + ' -'.join('2a 3ab 4xy'.split())
Out[8]: '-2a -3ab -4xy'

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list