OLD | NEW |
(Empty) | |
| 1 library substituting_strings_test; |
| 2 |
| 3 import 'package:unittest/unittest.dart'; |
| 4 |
| 5 void main() { |
| 6 group('substituting strings based on regExp matches', () { |
| 7 test('using replaceAll()', () { |
| 8 expect('resume'.replaceAll(new RegExp(r'e'), '\u00E9'), equals('résumé')); |
| 9 }); |
| 10 |
| 11 test('using replaceFirst()', () { |
| 12 expect('0.0001'.replaceFirst(new RegExp(r'0+'), ''), equals('.0001')); |
| 13 }); |
| 14 |
| 15 test('using replaceAllMapped()', () { |
| 16 var heart = '\u2661'; |
| 17 var string = "I like Ike but I $heart Lucy"; |
| 18 var regExp = new RegExp(r'[A-Z]\w+'); |
| 19 expect(string.replaceAllMapped( |
| 20 regExp, (match) => match.group(0).toUpperCase()), |
| 21 equals('I like IKE but I ♡ LUCY')); |
| 22 }); |
| 23 |
| 24 }); |
| 25 } |
OLD | NEW |