scala 2.11.6
val fontColorMap = Map( "Good" -> "#FFA500", "Bad" -> "#0000FF")
val content = "Good or Bad?"
"(Bad|Good)".r.replaceFirstIn(content,s"""<font color="${fontColorMap("$1")}">$$1</font>""")
I want to replace the String using regex. In this case $$1 can fetch the matched string, but I dont know how to do it in ${}.
plus. I know that scala will translate the interpolation into something like this
new StringContext("""<font color=""",""">$$1</font>""").s(fontColorMap("$1"))
Thus it will fail. But, is there any way I can handle this gracefully?