Let say that there is a Map with key value pair or text like:
val pairs = Map(
"x1" -> "a",
"1" -> "xf",
"80" -> "AB"
)
Is there a way to add new column with regexp_replace invocation in cycle like that:
df.withColumn("newColumn", pairs.mapSomeHow((k,v) => regexp_replace(col("originalColumn"), k, v)))
E.g. newColumn will have value from originalColumn with "x1", "1", "80" strings replaced.
How to do that?