Last Updated: February 25, 2016
·
813
· eugener

Scala Regex extractor

Every Regex object in Scala has an extractor, which makes possible something like:

// Regex to split a date in the format Y/M/D.
val regex = "(\\d+)/(\\d+)/(\\d+)".r
val regex(year, month, day) = "2010/1/13"