square brackets in empty space

Shambhu Rai 1,411 Reputation points
2024-01-02T14:42:22.13+00:00

Hi Expert,

I am getting square brackets in empty spaces in databricks, i tired below but unable to remove it

[]

regexp_replace(col1, "[^a-zA-Z0-9]", "")

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,540 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 34,336 Reputation points Volunteer Moderator
    2024-01-02T20:36:10.1533333+00:00

    If your goal is to remove only the square brackets ([]), you should adjust your regular expression to specifically target those characters.

    
    regexp_replace(col1, "\\[|\\]", "")
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.