replaceBeforeFirst method

String replaceBeforeFirst(
  1. String pattern,
  2. String replacement
)

Replaces everything before the first occurrence of pattern.

Implementation

String replaceBeforeFirst(String pattern, String replacement) {
  final i = indexOf(pattern);
  if (i == -1) return this;
  return replacement + substring(i);
}