Skip to content

Instantly share code, notes, and snippets.

View refond's full-sized avatar
🎯
Focusing

Patrick Refondini refond

🎯
Focusing
View GitHub Profile
@davidallsopp
davidallsopp / phone_regex.scala
Last active April 27, 2018 13:44
Scala regex and pattern matching example - phone numbers
import scala.util.matching.Regex
object regex {
val number = "07923 874123" //> number : String = 07923 874123
val pattern = """(\d{5})[ -]?(\d{6})""" //> pattern : String = (\d{5})[ -]?(\d{6})
number.matches(pattern) //> res0: Boolean = true
// Compiled pattern