Я пытаюсь сопоставить текстовый шаблон [[1st-word | 2nd-word]]
или [[word]]
с использованием java regex span на нескольких строках. Например, мой кодJava Regex не собирает множественные вхождения по нескольким строкам
String tStr = "Computer science in sport''' is an interdisciplinary discipline
that has its goal in combining the theoretical as well as practical aspects
and methods of the areas of [[Information technology|informatics]] and [[sport
science]]. The main emphasis of the [[interdisciplinarity]] is placed on the
application and use of computer-based but also mathematical techniques in sport
science, aiming in this way at the support and advancement of theory and practice
in sports.<ref>{{cite web|author=Daniel Link & Martin Lames|title=Sport
Informatics – Historical Roots";
String validateRegex = "(\\[\\[)(:?)(\\w+)(\\|?)(\\w*)(\\]\\])";
Pattern pattern = Pattern.compile(validateRegex, Pattern.MULTILINE);
Matcher matcher = pattern.matcher(tStr);
while (matcher.find()) {
System.out.println(matcher.group()+"\n");
}
выходы [[interdisciplinarity]]
. Однако я ожидал увидеть
[[Information technology|informatics]]
[[sport science]]
[[interdisciplinarity]]
Может кто-нибудь помочь в разъяснении, где моя ошибка? и дайте мне пример, как правильно получить ожидаемый шаблон?
Строка не является многострочной, если в ней нет '\ n'. Запись его в несколько строк в источнике не добавляет его. – zapl