Created
May 19, 2015 14:13
-
-
Save aphexmunky/2ff1d3e56796916a15fa to your computer and use it in GitHub Desktop.
Pattern matching regex types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val LoglevelPattern = """.*\[(DEBUG|INFO|WARN|ERROR)\].*""".r | |
| LoglevelPattern: scala.util.matching.Regex = .*\[(DEBUG|INFO|WARN|ERROR)\].* | |
| """1. [INFO] starting system""" match { case LoglevelPattern(level) => level; case other => "OTHER" } | |
| res1: String = INFO | |
| """1. [WARNING] starting system""" match { case LoglevelPattern(level) => level; case other => "OTHER" } | |
| res2: String = OTHER | |
| """1. [WARNING] starting system""" match { case LoglevelPattern(level) => level; case other => "OTHER" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment