fork download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  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. final String regex = "^(?![0.]*$)\\d{0,8}(?:\\.\\d{1,2})?$";
  13. final String string = "0000.00\n"
  14. + "00.00\n"
  15. + "0.0\n"
  16. + "100.00";
  17.  
  18. final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
  19. final Matcher matcher = pattern.matcher(string);
  20.  
  21. while (matcher.find()) {
  22. System.out.println(matcher.group(0));
  23. }
  24. }
  25. }
Success #stdin #stdout 0.07s 33816KB
stdin
Standard input is empty
stdout
100.00