allAfter method

String allAfter (
  1. Pattern pattern
)

Searches the string for the first occurrence of a pattern and returns everything after that occurrence.

Returns "" if no occurrences were found.

Example:

"value=1".allAfter("=");                 // "1"
"i like turtles".allAfter("like")        // " turtles"
"i   like cats".allAfter(RegExp("\\s+")) // "like cats"

Implementation

String allAfter(Pattern pattern) {
  ArgumentError.checkNotNull(pattern, "pattern");
  var matchIterator = pattern.allMatches(this).iterator;

  if (matchIterator.moveNext()) {
    var match = matchIterator.current;
    var length = match.end - match.start;
    return substring(match.start + length);
  }
  return "";
}