Re: [Tutor] substitute using re.sub

2017-10-25 Thread Peter Otten
kumar s via Tutor wrote: > Hi group, I am trying to substitute in the following way and i cannot. > Could you point out whats wrong in what i am doing. > z'.|D' re.sub(z,'1',z)'111' > I just want only '1' and not '111'. > I want:>>> re.sub(z,'1',z)'1' > re.sub is repeatedly inserting 3

[Tutor] substitute using re.sub

2017-10-25 Thread kumar s via Tutor
Hi group, I am trying to substitute in the following way and i cannot. Could you point out whats wrong in what i am doing.  >>> z'.|D' >>> re.sub(z,'1',z)'111' I just want only  '1' and not '111'.  I want:>>> re.sub(z,'1',z)'1' re.sub is repeatedly inserting 3 times because z has .|D . How can I