fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.regex.Pattern;
  4. import java.util.regex.Matcher;
  5.  
  6. class Main
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. System.out.println(Pattern.matches("^\\[([a-zA-Z]+\\d+)?\\]$","[abc123]"));
  11. Pattern pattern = Pattern.compile("^\\[([a-zA-Z]+\\d+)?\\]$");
  12. Matcher matcher = pattern.matcher("[abc123]");
  13. while (matcher.find()) {
  14. System.out.println(matcher.group(1));
  15. }
  16. }
  17. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
true
abc123