parentPath method
String is divided by separator
and moved one level up.
Stringをseparator
で分割し一つ上の階層に移動します。
final path = "aaaa/bbbb/cccc/dddd";
final parentPath = path.parentPath(); // "aaaa/bbbb/cccc"
Implementation
String parentPath({String separator = "/"}) {
if (isEmpty) {
return this;
}
final path = trimString(separator);
return path.replaceAll(_tail, "").trimStringRight(separator);
}