Created
April 8, 2013 18:48
-
-
Save ilguzin/5339390 to your computer and use it in GitHub Desktop.
regular expression vs patterns matching in Scala
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 s = "Me Moscow 2012" | |
s: String = some text 2012 | |
scala> val PersonLocation = """(.+) (.+) (.+)""".r | |
PersonLocation: scala.util.matching.Regex = (.+) (.+) (.+) | |
scala> val PersonLocation(person, city, year) = s | |
person: String = Me | |
city: String = Moscow | |
year: String = 2012 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment