I am trying to carry out an ordering method based on certain criteria, one of them is by the first letter with which a title begins. But I run into the accents which I don't know how to evaluate with a regular expression.
For my ordering method, I first remove any title that contains a character at the beginning that is not a letter or a number.
The titles are already sorted from a query with SQLite
using theORDER BY
if (titulo.contains(RegExp(r'^\W'))) {
print(titulo);
}
Which also prints those that start with an accent ,
I/flutter (12242): ¡Cuánto me ama ! I/flutter (12242): Él corazón I/flutter (12242): Óyenos
Try doing what they suggest in the following answer . but i can't get it to work
Luckily there is already a package that does all the work, it's called
diacritic
, you can find it here: https://pub.dev/packages/diacritic#-readme-tab-And if you want to see how many regular expressions it uses, just check the source code: https://github.com/agilord/diacritic/blob/master/lib/src/replacement_map.dart
After that, the use is simple, you add it in
pubspec.yaml
and here is an example of use:Result