Transform scala inner map

hey i have Map like this:

val valueParameters = Map("key1"->"value","anotherkey1"->"value","thirdkey1"->"value","key2"->"value","anotherkey2"->"value","thirdkey2"->"value")

and pattern:

val pattern = """(?<=[a-zA-Z])\d{1,2}""".r

val result =  valueParameters.groupBy(x=>pattern.findAllIn(x._1).next().toInt).toSeq.sortBy(_._1).toMap

which gives: Map[Int,Map[String,String] and i want to remove the number from the first string of the second map which i dont need anymore so i can : result(1)("key") not result(1)("key1")


This should work

val result1 = { case (k,v) => 
  k -> { case (a,b) => 
    val a1 = a.takeWhile(! _.isDigit)
    a1 -> b

Note that while using mapValues would result in shorter code, mapValues is a lazy operation that will do the computation every time you access the map, whereas mapping the entries will result in the computation being done once, which is usually what you expect in scala.

Need Your Help

SQL Select * from multiple tables

php sql mysql database pdo

Using PHP/PDO/MySQL is it possible to use a wildcard for the columns when a select is done on multiple tables and the returned array keys are fully qualified to avoid column name clash? C# uploading big file and processing it

c# file-upload

I want to be able to upload file from my .aspx page to my web server so that it can be preocessed into a different format.