I'm trying to create a regex Pattern that will capture all occurrences of 6-digit integer values in a string. I don't want any subscripts of larger strings of digits - only numbers exactly 6 digits in length.
I'm stumped. Everything I've tried misses something or captures something it shouldn't.
String s = "123456the quick brown fox5551212 jumped 234567,345678, 456789.567890";
Pattern pattern = Pattern.compile("(\\d{6})");
Matcher matcher = pattern.matcher(s);
while (matcher.find())
System.err.println(matcher.group(1));
Should produce:
123456
234567
345678
456789
567890
I've tried bounding the capture group (\\d{6}) with combinations of \\D, \b, etc. to no avail.
Thanks.