summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2009-08-04 16:15:56 +0000
committerPhilipp Haller <hallerp@gmail.com>2009-08-04 16:15:56 +0000
commitedb1bf023beecabfaf92c599f9d2237a289a6119 (patch)
tree64bf849cb03de9aa682e40342010d7bbeff5d238
parentf046863f53a08bfde42733a27d2bc483a73765d1 (diff)
downloadscala-edb1bf023beecabfaf92c599f9d2237a289a6119.tar.gz
scala-edb1bf023beecabfaf92c599f9d2237a289a6119.tar.bz2
scala-edb1bf023beecabfaf92c599f9d2237a289a6119.zip
Applied patch for #2150.
-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>