fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String re = "-0+\\.(0)+\\b|\\.0+\\b|\\b0+(?=\\.\\d*[1-9])";
  13. String str = "2.0,3.00,-4.0,0.00,-0.00,0.03,2.01,0.001,-0.03,101,0.001,-0.03";
  14. String expected = "2,3,-4,0,0,.03,2.01,.001,-.03,101,.001,-.03";
  15. System.out.println(str.replaceAll(re, "$1").equals(expected)); // TRUE
  16. }
  17. }
Success #stdin #stdout 0.12s 320576KB
stdin
Standard input is empty
stdout
true