Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads'C1, C2 and C3'
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads'C1, C2 and C3'

From: Alan Green <alan.green@gmail.com>
Date: Tue Jul 12 2005 - 22:54:33 CEST

Ric Da Force wrote:
> Hi guys,
>
> Thank you all for your input! It was good to see so much convergence in the
> approach!

Just for divergence, you can also do this with regular expressions:

>>> import re
>>> re.sub("(.*),(.*)", r"\1 and\2", "C1, C2, C3")
'C1, C2 and C3'

Alan.
Received on Thu Sep 29 16:54:55 2005