@icchan119さんが投稿したコード一覧

正規表現

Apacheのログからipと日付の取り出し(httpd.conf直したほうが早いとか言わない(キリッ
Apacheのログからipと日付の取り出し(httpd.conf直したほうが早いとか言わない(キリッ
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") }}
コードを見る
  • タグ:
  • タグはありません

Stringのmap()

気分的にscala.collection.immutable.IndexedSeq[Char]になって欲し気がしないでもない。。。
気分的にscala.collection.immutable.IndexedSeq[Char]になって欲し気がしないでもない。。。
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))
コードを見る
  • タグ:
  • タグはありません