removePrefixOrSelf method
Returns a prefix-removed version if this string starts with prefix,
otherwise returns this string unchanged.
Examples:
- "prefixtest".removePrefixOrSelf("prefix") → "test"
- "test".removePrefixOrSelf("prefix") → "test"
Implementation
String removePrefixOrSelf(String prefix) {
if (startsWith(prefix)) {
return substring(prefix.length);
} else {
return this;
}
}