javaregexstring

Removing full stops from String


I am trying to remove full stops from a String. I have tried the below

titleAndBodyContainer = titleAndBodyContainer.replaceAll("\\.", " "); 

Unfortunately, this removed all other 'dots' as well. My paragraph includes dates like Jan.13, 2014 , words like U.S and numbers like 2.2. How can I remove only the full stops?


Solution

  • I'd do:

    titleAndBodyContainer = titleAndBodyContainer.replaceAll("\\.(?=\\s|$)", " ");