I am trying to fetch the nbr from a string given. I have used regex object. But Its giving me address value. Please explain why toArray is not giving the result.
ackage Phase1Training
object ScalaRegex {
def main(args: Array[String]): Unit = {
val numPattern = "[0-9]+".r
val address ="123 washington Road 102"
var zip = numPattern.findFirstIn(address)
println(zip)
**var matches = numPattern.findAllMatchIn(address).toArray** //Why this is giving the object address.
println (matches)
matches.foreach(println) //This is perfectly working.
Some(123) [Lscala.util.matching.Regex$Match;@30097f5f 123 102