title: How to escape ( parentheses in Spark Scala?
body: <p>I am trying to replace parentheses in a string (i.e. column names). It is working fine with white spaces but not with <code>(</code> parentheses. I tried <code>&quot;&quot;&quot;</code>, <code>\(</code>, <code>\\(</code> but I am always getting an error. I also tried this tip <a href="https://stackoverflow.com/questions/17341079/how-can-i-escape-special-symbols-in-scala-string">How can I escape special symbols in scala string?</a> but it did not help me. Can you please tell me how to solve this?</p>
  <pre><code>import org.apache.commons.lang3.StringEscapeUtils
  
  var newDf = df
    for(col &lt;- df.columns){
      newDf = newDf.withColumnRenamed(col,col.replaceAll(StringEscapeUtils.escapeJava(&quot;(&quot;), &quot;_&quot;))
      newDf = newDf.withColumnRenamed(col,col.replaceAll(&quot; &quot;, &quot;-&quot;))
  }
  </code></pre>
  <p>Thanks a lot!</p>