I have inputs like this.
And I walked 0.69 miles. I had a burger..I took tea...I had a coffee
And my goal is to convert two or more dots to a single dot and then a space so that input become correct according to grammar proper ending. Target output is:
And I walked 0.68 miles. I had a burger. I took tea. I had a coffee
I have made a regular expression for this is as:
[\\.\\.]+
I checked it on Regex Tester it will not work as I wished. As it will also included 0.69
and ending of this line .
too which I don't want. If anybody can help me in this I will be thankful to you.
You can use:
str = str.replaceAll("\\.{2,}", ". ");
RegEx Demo
\\.{2,}
matches 2 or more consecutive dots and ". "
replaced them by a dot and space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With