rightOf method

String rightOf(
  1. String char
)

Returns the right side of the String starting from char.

If char doesn't exist, null is returned.

Example

 String s = 'peanutbutter';
 String foo = s.rightOf('peanut'); // returns 'butter'

Implementation

String rightOf(String char) {
  if (this.isBlank) {
    return this;
  }

  int index = this.indexOf(char);

  if (index == -1) {
    throw Exception('Character not found');
  }
  return this.substring(index + char.length, this.length);
}