String s = "abcdere,fd,,,,123fda";Pattern pattern = Pattern.compile("\\d+");Matcher matcher = pattern.matcher(s);if (matcher.find()){ System.out.println(matcher.group());}