From edb1bf023beecabfaf92c599f9d2237a289a6119 Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Tue, 4 Aug 2009 16:15:56 +0000 Subject: Applied patch for #2150. --- src/library/scala/runtime/RichString.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 prefix stripped. */ + def stripPrefix(prefix: String) = + if (self.startsWith(prefix)) self.substring(prefix.length) + else self + + /** Returns this string with the given suffix stripped. */ + def stripSuffix(suffix: String) = + if (self.endsWith(suffix)) self.substring(0, self.length() - suffix.length) + else self + /**

* For every line in this string: *

-- cgit v1.2.3