takeTo method

String takeTo(
  1. Pattern pattern
)

Returns the string prefix up to the first occurrence of pattern. If the pattern is not found return the whole string.

Implementation

String takeTo(Pattern pattern) {
  final index = indexOf(pattern);
  if (index < 0) return substring(0);
  return substring(0, index);
}