Created
November 3, 2016 21:22
-
-
Save animatedlew/6b809d7cbc321e1a04e68babd7d0a3eb to your computer and use it in GitHub Desktop.
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
| // define your regex groups: one that grabs everything from the end of the line, | |
| // and another group that grabs everything else... | |
| val pathExtractor = """(.*/)(.*)$""".r | |
| // then you can use unapply like this... | |
| val pathExtractor(path, file) = "some/long/path/file.ext" | |
| // or like this (recommended) | |
| "some/long/path/file.ext" match { | |
| case pathExtractor(p, f) => p -> f | |
| case _ => ("NO_PATH", "NO_FILE") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment