How would I do this with python :
if I have a string formatted like :
A..a.b.c
To make it like :
A.a.b.c
But I do not know beforehand how many dots I have ?
It’s like the tr -s function in linux
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want to replace every run of TWO or more dots by a single dot. That is achieved like this:
You don’t want and don’t need to replace every run of ONE or more dots by a single dot.
That produces the same result but does pointless substitutions of lone dots (3 on your example) and is consequently much slower.
Timings: