Код: Выделить всё
public class RegexTestPatternMatcher {
public static final String EXAMPLE_TEST = "This is my first photo.jpg string and this my second photo2.jpg String";
public static void main(String[] args) {
Pattern pattern = Pattern.compile("\\w+\\.jpg");
Matcher matcher = pattern.matcher(EXAMPLE_TEST);
// check all occurance
while (matcher.find()) {
System.out.println(matcher.group());
}
}
}
< /code>
Вывод: < /p>
photo.jpg
photo2.jpg
Подробнее здесь: https://stackoverflow.com/questions/216 ... sing-regex