W3cubDocs

/Dart 2

replaceFirst method

String replaceFirst (Pattern from, String to, [ int startIndex = 0 ])

Returns a new string in which the first occurrence of from in this string is replaced with to, starting from startIndex:

'0.0001'.replaceFirst(new RegExp(r'0'), ''); // '.0001'
'0.0001'.replaceFirst(new RegExp(r'0'), '7', 1); // '0.7001'

Implementation

String replaceFirst(Pattern from, String to, [int startIndex = 0]);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-core/String/replaceFirst.html