To replace all the substring of a string we make use of replaceAll method in Dart. This method replaces all the substring in the given string to the desired substring. Returns a new string in which the non-overlapping substrings matching from (the ones iterated by from.allMatches(this String)) are replaced by the literal string replace.
Syntax: String_name.replaceAll (Old_String_Pattern, New_String_Pattern);
In the above sequence:
- String_name is the name of the string in which operation is to be done. It could be the string itself.
- Old_String_Pattern is the pattern present in the given string.
- New_String_Pattern is the new pattern that is to be replaced with the old pattern.
Replacing the substring in the given string.
In the above example the substring “GeeksForGeeks” is replaced by another string “Geek!”.
Using chain of replaceAll() method to change the string in dart.
Welcome Geek :)
In the above example the substring “GeeksForGeeks” is replaced by another string “Geek!” and then “!” is replaced by ” : )”.
- Rust vs Dart - Which is More Likely to Replace C++?
- Dart - Splitting of String
- How to Find the Length of a String in Dart?
- How to Check String is Empty or not in Dart?
- Dart - String codeUnits Property
- Dart - Convert All Characters of a String in Lowercase
- Dart - String toUpperCase() Function with Examples
- How to Combine Lists in Dart?
- Basics of Numbers in Dart
- Dart - Super and This keyword
- Dart - Standard Input Output
- Generators in Dart
- Dart - Classes And Objects
- Operators in Dart
- Dart - Loops
- Switch Case in Dart
- Dart - Loop Control Statements (Break and Continue)
- Dart Programming - Functions
- Instance and class methods in Dart
- Abstract Classes in Dart
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.