summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/runtime/RichString.scala10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala
index 6fc8f1e9a6..6d36237359 100644
--- a/src/library/scala/runtime/RichString.scala
+++ b/src/library/scala/runtime/RichString.scala
@@ -134,6 +134,16 @@ class RichString(val self: String) extends Proxy with Vector[Char] with VectorTe
new String(chars)
}
+ /** Returns this string with the given <code>prefix</code> stripped. */
+ def stripPrefix(prefix: String) =
+ if (self.startsWith(prefix)) self.substring(prefix.length)
+ else self
+
+ /** Returns this string with the given <code>suffix</code> stripped. */
+ def stripSuffix(suffix: String) =
+ if (self.endsWith(suffix)) self.substring(0, self.length() - suffix.length)
+ else self
+
/** <p>
* For every line in this string:
* </p>