Created
April 3, 2014 03:53
-
-
Save phoenix24/9948041 to your computer and use it in GitHub Desktop.
scala regex, awesomeness!
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
| scala> val date = "11/01/20101" | |
| date: String = 11/01/20101 | |
| scala> val date = "11/01/2010" | |
| date: String = 11/01/2010 | |
| scala> val Date = """(\d\d)/(\d\d)/(\d\d\d\d)""" | |
| Date: String = (\d\d)/(\d\d)/(\d\d\d\d) | |
| scala> val Date = """(\d\d)/(\d\d)/(\d\d\d\d)""".r | |
| Date: scala.util.matching.Regex = (\d\d)/(\d\d)/(\d\d\d\d) | |
| scala> val Date(day, month, year) = date | |
| day: String = 11 | |
| month: String = 01 | |
| year: String = 2010 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment