dart-exercism/acronym/lib/acronym.dart
2024-10-14 11:37:17 +02:00

10 lines
220 B
Dart

class Acronym {
String abbreviate(String phrase) {
return phrase
.split(RegExp(r"\s+|\-+|_+"))
.where((word) => word.isNotEmpty)
.map((word) => word[0].toUpperCase())
.join();
}
}