java正则表达式和linux表达式是有一些不一样的
def test11(): Unit ={ val date = "2017-08-09" val warn = "WARN" val strs = Array("2017-08-09 10:24:11,040 RN org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Checkpoint done. New Image Size: 117430", "2017-08-09 11:24:11,570 WARN org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Checkpoint done. New Image Size: 117230", "2017-08-09 11:24:11,570 WA org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Checkpoint done. New Image Size: 117230", "2017-08-09 11:24:11,570 WARN org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Checkpoint done. New Image Size: 117230") strs.filter(_.matches(".*2017-08-09.*WARN.*")).foreach(println(_)) }