Splunk Search

Unmatched parentheses error with replace

bruceclarke
Contributor

The following search is complaining about an unmatched parenthesis. Since the parentheses are inside of quotes, shouldn't the parser not care? Does anyone have a workaround?

{baseSearch}
| eval BaselineActual=replace(BaselineActual,") (",")<NEWLINE>(")
| makemv delim="<NEWLINE>" BaselineActual 
0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi bruceclarke,

you need to escape the parentheses so Splunk will not use them:

 | stats count | eval foo="This is ) ( my message" | eval BaselineActual=replace(foo,"\) \(",")<NEWLINE>(")
 | makemv delim="<NEWLINE>" BaselineActual

or adapted to your search:

 {baseSearch}
 | eval BaselineActual=replace(BaselineActual,"\) \(",")<NEWLINE>(")
 | makemv delim="<NEWLINE>" BaselineActual 

Hope that helps ...

cheers, MuS

View solution in original post

MuS
SplunkTrust
SplunkTrust

Hi bruceclarke,

you need to escape the parentheses so Splunk will not use them:

 | stats count | eval foo="This is ) ( my message" | eval BaselineActual=replace(foo,"\) \(",")<NEWLINE>(")
 | makemv delim="<NEWLINE>" BaselineActual

or adapted to your search:

 {baseSearch}
 | eval BaselineActual=replace(BaselineActual,"\) \(",")<NEWLINE>(")
 | makemv delim="<NEWLINE>" BaselineActual 

Hope that helps ...

cheers, MuS

bruceclarke
Contributor

Thanks MuS! I was actually playing around with this more and came to a similar conclusion. Ultimately this didn't work for me either.

Turns out that what I assumed was a space might actually be some other whitespace character. I was able to use the following to get it to work (note that "\s" matches any whitespace character):
{baseSearch}
| eval BaselineActual=replace(BaselineActual,")\s(",")(")
| makemv delim="" BaselineActual

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...