onlyGreek property
String
onlyGreek
Returns only the Greek characters from the String
.
Example
String foo = '4*%^55/σοφ4e5523ια';
String onlyGreek = foo.onlyGreek; // returns 'σοφια'
String foo2 = '4*%^55/σοφ4e5523ια aaggαγάπ112η';
String onlyGreek2 = foo2.onlyGreek; // returns 'σοφια αγάπη'
Implementation
String get onlyGreek {
if (this.isBlank) {
return this;
}
// ignore: unnecessary_raw_strings
var regex = RegExp(r'([^α-ωΑ-ΩίϊΐόάέύϋΰήώΊΪΌΆΈΎΫΉΏ\s]+)');
return this.replaceAll(regex, '');
}