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.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. String line = "$data.[*].author";
  14. String pattern = "^\\$([\\w]+)(\\..+?)((?:\\.(?:(?:min|max|avg)\\(\\)))?$)";
  15. Pattern r = Pattern.compile(pattern);
  16. Matcher m = r.matcher(line);
  17.  
  18. if (m.find()) {
  19. System.out.println(m.group(1) + "\n" + m.group(2) + "\n" + m.group(3));
  20. }
  21. }
  22. }
  23.  
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
data
.[*].author