splitMapJoin method Null safety
Splits the string, converts its parts, and combines them into a new string.
pattern
is used to split the string into parts and separating matches.
Each match is converted to a string by calling onMatch
. If onMatch
is omitted, the matched string is used.
Each non-matched part is converted by a call to onNonMatch
. If
onNonMatch
is omitted, the non-matching part is used.
Then all the converted parts are combined into the resulting string.
'Eats shoots leaves'.splitMapJoin((new RegExp(r'shoots')),
onMatch: (m) => '${m.group(0)}',
onNonMatch: (n) => '*'); // *shoots*
Implementation
String splitMapJoin(Pattern pattern,
{String Function(Match)? onMatch, String Function(String)? onNonMatch});