RosettaCodeData/Task/Strip-block-comments/Scala/strip-block-comments-3.scala

8 lines
235 B
Scala
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
def strip3(x: String, s: String = "/*", e: String = "*/"): String = x.indexOf(s) match {
case -1 => x
case i => x.indexOf(e, i + s.length) match {
case -1 => x
case j => strip2(x.take(i) + x.drop(j + e.length), s, e)
}
}