val regex = "([0-9]+.[0-9]+.[0-9]+.[0-9]+).*([0-3][0-9].[A-Z][a-z][a-z].20[0-1][0-9]:[0-2][0-9]:[0-5][0-9]:[0-5][0-9]).*".r; scala.io.Source.fromFile("./access_log").getLines().foreach( x => { x match { case regex(ip,date) => {println(ip +" at " + date) } case _ => println("no match") }}
scala> "1234567789".map( x => x ) res0: String = 1234567789 scala> "1234567789".map( x => Option(x) ) res1: scala.collection.immutable.IndexedSeq[Option[Char]] = Vector(Some(1), Some(2), Some(3), Some(4), Some(5), Some(6), Some(7), Some(7), Some(8), Some(9))