Skip to content

Instantly share code, notes, and snippets.

@ilguzin
Created April 8, 2013 18:48
Show Gist options
  • Save ilguzin/5339390 to your computer and use it in GitHub Desktop.
Save ilguzin/5339390 to your computer and use it in GitHub Desktop.
regular expression vs patterns matching in Scala
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