fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  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. digest("\\60000000000");
  13. digest("\\6000000000000");
  14. digest("\\60#########");
  15. digest("\\60############");
  16. digest("\\60############6");
  17. digest("\\60########A####");
  18. digest("\\lala60000000000");
  19. digest("\\60#####6######");
  20. digest("\\60#####6##A####");
  21. }
  22. private static void digest(String formatTxt) {
  23. System.out.println("Doing: " + formatTxt);
  24. Pattern numPattern = Pattern.compile("(\\\\)(\\d+)(#*)");
  25. Matcher m = numPattern.matcher(formatTxt);
  26. if (m.matches()) {
  27. System.out.println("Pattern matched!");
  28. System.out.println("1. " + m.group(1));
  29. System.out.println("2. " + m.group(2));
  30. System.out.println("3. " + m.group(3));
  31. System.out.println("");
  32. }
  33.  
  34. }
  35. }
Success #stdin #stdout 0.07s 2841600KB
stdin
Standard input is empty
stdout
Doing: \60000000000
Pattern matched!
1. \
2. 60000000000
3. 

Doing: \6000000000000
Pattern matched!
1. \
2. 6000000000000
3. 

Doing: \60#########
Pattern matched!
1. \
2. 60
3. #########

Doing: \60############
Pattern matched!
1. \
2. 60
3. ############

Doing: \60############6
Doing: \60########A####
Doing: \lala60000000000
Doing: \60#####6######
Doing: \60#####6##A####