Splunk Search

How do you remove specific special characters from a field value?

RonWonkers
Path Finder

Hi, I have a field called "Employee_Email". This field contains the value:

["firstname.lastname@gmail.com"]

How do I remove the special characters [" and "]?

 

I tried: 

| eval test1 = replace (Employee_Email "[" , "")

 

But when I tried to remove either [ or " it gives me the following errors:

Error in 'EvalCommand': Regex: missing terminating ] for character class

Or:

Unbalanced quotes.

 

Is there a way to ignore the normal effect of [ and "?

Labels (6)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You need to escape the square brackets and double quotes

| eval test1=replace(replace(Employee_Email,"\[\"",""),"\"\]","")

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

You need to escape the square brackets and double quotes

| eval test1=replace(replace(Employee_Email,"\[\"",""),"\"\]","")

RonWonkers
Path Finder

Tried this and it worked thanks

0 Karma

PickleRick
SplunkTrust
SplunkTrust

As an alternative you can use other functions

| eval trimmed_email=trim(Employee_Email,"\"[]")

or

| eval substr_email=substr(Employee_Email,3,len(Employee_Email)-4)

RonWonkers
Path Finder

This is indeed a nice alternative thank you!

0 Karma

RonWonkers
Path Finder

Edit:

I tried: 

| eval test1 = replace (Employee_Email, "[" , "")
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...