I have a string like
String string = \"number0 foobar number1 foofoo number2 bar bar bar bar number3 foobar\";
I need a regex to give me th
because .* is a greedy pattern. use .*? instead of .*
.*
.*?
Pattern pattern = Pattern.compile("number\\d+(.*?)(number\\d+)"); Matcher matcher = pattern.matcher(string); while(matcher.find();){ out(matcher.group()); }