dart string replace code example

Example 1: flutter replace character in string

newString = 'resume';
newString.replaceAll('e', 'é'); // it returns the string   'résumé'

// And you can use a regex to search like a needle in a haystack:
'resume'.replaceAll(RegExp(r'e'), ‘é’); // 'résumé'

Example 2: replace string in dart,replace string in dart using regex

var greetingTemplate = 'Hello, NAME!';
var greeting =
    greetingTemplate.replaceAll(RegExp('NAME'), 'Bob');

// greetingTemplate didn't change.
assert(greeting != greetingTemplate);

Tags:

Misc Example