fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String str = "Rate is : .97 . XXXXXXXXX do you want . 87 to perform another calculation . ";
  12. String pattern = "(?<!\\S)\\.[0-9]";
  13. System.out.println(str.replaceAll(pattern, "0$0"));
  14. }
  15. }
Success #stdin #stdout 0.08s 33672KB
stdin
Standard input is empty
stdout
Rate is : 0.97  . XXXXXXXXX do you want . 87 to perform another calculation .