RosettaCodeData/Task/Regular-expressions/Dart/regular-expressions.dart
2014-04-02 16:56:35 +00:00

10 lines
293 B
Dart

RegExp regexp = new RegExp(r'\w+\!');
String capitalize(Match m) => '${m[0].substring(0, m[0].length-1).toUpperCase()}';
void main(){
String hello = 'hello hello! world world!';
String hellomodified = hello.replaceAllMapped(regexp, capitalize);
print(hello);
print(hellomodified);
}