fork download
  1. import java.util.regex.*;
  2.  
  3. class UnisClass {
  4. private static final Pattern PATTERN =
  5. Pattern.compile("^M{0,3}(C[DM]|D?C{0,3})(X[LC]|L?X{0,3})(I[VX]|V?I{0,3})$");
  6. public static void main (String[] args) {
  7. String ha = "XXXIV";
  8. Matcher matcher = PATTERN.matcher(ha);
  9. System.out.println(matcher.matches());
  10. if (matcher.matches()) {
  11. System.out.println(matcher.group());
  12. System.out.println(matcher.group(1));
  13. System.out.println(matcher.group(2));
  14. System.out.println(matcher.group(3));
  15. }
  16. }
  17. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
true
XXXIV

XXX
IV