Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
object StripComments {
|
||||
def stripComments1(s:String, markers:String =";#")=s takeWhile (!markers.contains(_)) trim
|
||||
|
||||
// using regex and pattern matching
|
||||
def stripComments2(s:String, markers:String =";#")={
|
||||
val R=("(.*?)[" + markers + "].*").r
|
||||
(s match {
|
||||
case R(line) => line
|
||||
case _ => s
|
||||
}) trim
|
||||
}
|
||||
|
||||
def print(s:String)={
|
||||
println("'"+s+"' =>")
|
||||
println(" '"+stripComments1(s)+"'")
|
||||
println(" '"+stripComments2(s)+"'")
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
print("apples, pears # and bananas")
|
||||
print("apples, pears ; and bananas")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue