removePrefixIfPresent method

String removePrefixIfPresent(
  1. String toRemove
)

Remove the prefix of a String if present or return current String.

Implementation

String removePrefixIfPresent(String toRemove) {
  if (!startsWith(toRemove)) {
    return this;
  }

  return replaceFirst(toRemove, "");
}