cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

regexp_extract Error when put { in pattern

William_Scardua
Valued Contributor

HI guys,

I tried to use the regex_extract but when I put { in pattern I received error

display(
    df_containerlog.withColumn('reg', regexp_extract(col('LogEntry'), "((^.*))({'data':)", 1))
)

 

error-regex.png

have any idea

Thank you

2 REPLIES 2

-werners-
Esteemed Contributor III

what do you want to achieve with the curly brace?  It is a regex character so you can't just add it.
If you want to match on it, you should escape it and perhaps even put it within the quotes.
You can always test your regex in online tools like regex101 or regexr or ... very handy

Amine
Databricks Employee
Databricks Employee

Hello William,

You have to escape the { as it is a special char in case of regex.

"((^.*))(\{'data':)"

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now