fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.Scanner;
  5. import java.util.regex.Matcher;
  6. import java.util.regex.Pattern;
  7.  
  8. class Ideone
  9. {
  10. static int kills = 10;
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. System.out.println("Kill count command: ~killc [username]");
  14. Scanner userInt = new Scanner(System.in);
  15. String regex = "^~killc\\h+(\\S+(?:\\h+\\S+)*)$";
  16. String userInput = userInt.nextLine();
  17.  
  18. Pattern pattern = Pattern.compile(regex);
  19. Matcher matcher = pattern.matcher(userInput);
  20.  
  21. if (matcher.find()) {
  22. for (String username : matcher.group(1).split(" "))
  23. System.out.printf("%s has " + kills + " kills.\n",username);
  24. }
  25. }
  26. }
Success #stdin #stdout 0.17s 53712KB
stdin
~killc test1 test2
stdout
Kill count command: ~killc [username]
test1 has 10 kills.
test2 has 10 kills.