splitOnce method

Tuple2<String, String> splitOnce(
  1. Pattern p
)

Splits the string on the first occurrence of the specified delimiter and returns prefix before delimiter and suffix after delimiter.

Implementation

Tuple2<String, String> splitOnce(Pattern p) {
  final it = p.allMatches(this).iterator;
  if (it.moveNext()) {
    final match = it.current;
    return Tuple2(substring(0, match.start), substring(match.end));
  }

  return const Tuple2('', '');
}