Re: How to replace a comma

2006-12-18 Thread Hendrik van Rooyen
"Lad" <[EMAIL PROTECTED]> top posted: > > re's are a pain. Do this instead: > > > > >>> s = "hello, goodbye,boo" > > >>> s.replace(', ',',') > > 'hello,goodbye,boo' > > >>> _.replace(',',', ') > > 'hello, goodbye, boo' > Thank you for ALL for help. > Hendrik, > your solution works great but >

Re: How to replace a comma

2006-12-18 Thread Lad
Nick Craig-Wood wrote: > Lad <[EMAIL PROTECTED]> wrote: > > In a text I need to add a blank(space) after a comma but only if > > there was no blank(space) after the comman If there was a > > blank(space), no change is made. > > > > I think it could be a task for regular expression but can not

Re: How to replace a comma

2006-12-18 Thread Jussi Salmela
Lad kirjoitti: > > Thank you for ALL for help. > Hendrik, > your solution works great but > what is `_` in > _.replace(',',', ') > > for? When you are trying things out in the Python shell IDLE, _ is a shorthand way to use the last value printed by IDLE. Thus when s.replace(', ',',') p

Re: How to replace a comma

2006-12-18 Thread Duncan Booth
"Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > From: "Lad" <[EMAIL PROTECTED]> wrote: > > >> In a text I need to >> add a blank(space) after a comma but only if there was no blank(space) >> after the comman >> If there was a blank(space), no change is made. >> >> I think it could be a task f

Re: How to replace a comma

2006-12-18 Thread Nick Craig-Wood
Lad <[EMAIL PROTECTED]> wrote: > In a text I need to add a blank(space) after a comma but only if > there was no blank(space) after the comman If there was a > blank(space), no change is made. > > I think it could be a task for regular expression but can not > figure out the correct regular e

Re: How to replace a comma

2006-12-18 Thread Lad
Thank you for ALL for help. Hendrik, your solution works great but what is `_` in _.replace(',',', ') for? Thank you La. > re's are a pain. Do this instead: > > >>> s = "hello, goodbye,boo" > >>> s.replace(', ',',') > 'hello,goodbye,boo' > >>> _.replace(',',', ') > 'hello, goodbye, boo' > >>>

Re: How to replace a comma

2006-12-18 Thread Hendrik van Rooyen
From: "Lad" <[EMAIL PROTECTED]> wrote: > In a text I need to > add a blank(space) after a comma but only if there was no blank(space) > after the comman > If there was a blank(space), no change is made. > > I think it could be a task for regular expression but can not figure > out the correct re

Re: How to replace a comma

2006-12-18 Thread Jon Clements
Lad wrote: > In a text I need to > add a blank(space) after a comma but only if there was no blank(space) > after the comman > If there was a blank(space), no change is made. > > I think it could be a task for regular expression but can not figure > out the correct regular expression. > Can anyon

Re: How to replace a comma

2006-12-18 Thread Peter Otten
Lad wrote: > In a text I need to > add a blank(space) after a comma but only if there was no blank(space) > after the comman > If there was a blank(space), no change is made. >>> s = "alpha, beta,gamma, delta" >>> ", ".join(t.replace(",", ", ") for t in s.split(", ")) 'alpha, beta, gamma, delta

How to replace a comma

2006-12-18 Thread Lad
In a text I need to add a blank(space) after a comma but only if there was no blank(space) after the comman If there was a blank(space), no change is made. I think it could be a task for regular expression but can not figure out the correct regular expression. Can anyone help, please? Thank you L.