In my scala program, I want to use a pattern match to test whether there is a valid .csv file in the input path. path ="\DAP\TestData\test01.csv" val regex=""".csv$""".r.unanchored
I tried to use the previous regex to match the string, it worked, but when it went to match pattern, it cannot work.
path ="\DAP\TestData\test01.csv"
val regex="""\.csv$""".r.unanchored
path match {
case regex(type) =>println(s"$type matched")
case _ =>println("something else happeded")
}
I need to successfully print information like ".csv matched". Could anyone help me with this issue? I m really confused by this issue. Thanks