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

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -