fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.*;
  4. import java.util.regex.*;
  5.  
  6. class Main
  7. {
  8. private static final Pattern pattern = Pattern.compile("^((.+)_[^_]+)_([^_]+)$");
  9.  
  10. public static List<String> split(String input) {
  11. final Matcher matcher = pattern.matcher(input);
  12. if (!matcher.matches()) {
  13. return null;
  14. }
  15. return Arrays.asList(matcher.group(1), matcher.group(2), matcher.group(3));
  16. }
  17.  
  18. public static void main (String[] args)
  19. {
  20. System.out.println(split("S1_T1_VIEW"));
  21. System.out.println(split("S1_T1_C1_DELETE"));
  22. }
  23. }
Success #stdin #stdout 0.06s 380224KB
stdin
Standard input is empty
stdout
[S1_T1, S1, VIEW]
[S1_T1_C1, S1_T1, DELETE]