scala - Using regex to access values from a map in keys -



scala - Using regex to access values from a map in keys -

val m = map("a"->2,"ab"->3,"c"->4) scala> m.get("a"); scala> println(res.get) 2 scala> m.get(/a\.*/) // or similar.

can list of key-value pairs key contains "a" without having iterate on entire map , doing simple specifying regex in key value?

thanks in advance!

no, cannot without iterating on entire map. in fact, can't think of single info construction allow it, nil of api.

of course, iterating pretty simple:

m.filterkeys(_ matches "a.*")

regex scala

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -