import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\b\\p{Greek}+";
final String string = "Ὁμώνυμα λέγεται Aequivoca dicuntur ὧν ὄνομα μόνον κοινόν, quorum nomen solum commune est\n"
+ "ὁ δὲ κατὰ τοὔνομα λόγος τῆς οὐσίας ἕτερος secundum nomen vero substantiae ratio diversa, οἷον ζῷον ut animal ὅ τε ἄνθρωπος καὶ τὸ γεγραμμένον homo et quod pingitur· \n\n\n"
+ "ἀ·κρασία, -ας, ἡ\n"
+ "Noun (Fem. 1st Decl.)\n\n"
+ "Not all forms below are necessarily attested. Highlighted words may or may not be a match to the GNT or LXX, if another word also inflects the same way.\n\n"
+ "1st Decl. Feminine Noun\n"
+ "Contracted Uncontracted\n"
+ "Sg Voc ακρασια ακρασι·α\n"
+ "Nom\n"
+ "Acc ακρασιαν[GNT] ακρασι·αν\n"
+ "Dat ακρασιᾳ ακρασι·ᾳ\n"
+ "Gen ακρασιας[GNT] ακρασι·ας\n"
+ "Pl Voc ακρασιαι ακρασι·αι\n"
+ "Nom\n"
+ "Acc ακρασιας[GNT] ακρασι·ας\n"
+ "Dat ακρασιαις[LXX] ακρασι·αις\n"
+ "Gen ακρασιων ακρασι·ων\n";
final Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CASE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html