fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4. class Ideone
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String s = "abc:1234567,cd:2345678,efg:3456789012";
  9. Pattern pattern = Pattern.compile("\\b(?<!abc:)\\d{7}\\b");
  10. Matcher matcher = pattern.matcher(s);
  11. while (matcher.find()){
  12. System.out.println(matcher.group());
  13. }
  14. }
  15. }
Success #stdin #stdout 0.09s 48624KB
stdin
Standard input is empty
stdout
2345678