Код: Выделить всё
Arsenal
Manchester United
Chelsea
Liverpool
...
...
Manchester City
Real Madrid
< /code>
Предположим, что мне нужно найти строки, начинающиеся с «Манчестер», у меня есть ниже Regex. < /p>
Pattern clubman = Pattern.compile("Manchester.*");
Matcher matche = clubman.matcher(fileString);
if (matche.find()) {
System.out.println("Manchester club is :"
+ matche.group(0));
}
но Pattern.compile находит последний матч, то есть Manchester City .
>
Подробнее здесь: https://stackoverflow.com/questions/397 ... rn-matcher