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. /* Name of the class has to be "Main" only if the class is public. */
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String[] in = { "A.A2.ABC.2014071",
  12. "3.M1.MMB.2014071"};
  13.  
  14. Pattern p = Pattern.compile("\\w.[A-Z]\\d.[A-Z]{3}.\\d{7}");
  15. for (String s: in) {
  16. Matcher m = p.matcher(s);
  17. while (m.find()) {
  18. System.out.println("Result: " + m.group().substring(2));
  19. }
  20. }
  21.  
  22. }
  23. }
Success #stdin #stdout 0.07s 381248KB
stdin
Standard input is empty
stdout
Result: A2.ABC.2014071
Result: M1.MMB.2014071