Splunk Search

How do you include a literal double quote character in a Splunk Regex

jbrenner
Path Finder

I'm using the _rex command and I want to create a regular expression that contains a literal double quote character. How do I do this?

Thanks,
Jonathan

mayurr98
Super Champion

Hey try this

you can use \ to escape “

For example

Suppose you have user=“xyz” in the event and you want to extract xyz then you can use below regex

| rex field=_raw  “user=\”(?P<user>[^\”])”

You can use regex101.com to learn more !
Let me know if this helps you.

mayurr98
Super Champion

If you provide a sample event and tell us want you want to extract then we can write regex for you !
Provide sample event

0 Karma

elliotproebstel
Champion

You can escape the double-quote by using a backslash. Here's some sample run-anywhere code:

|makeresults 
| eval tf="contains a literal quote \" followed by stuff"
| rex field=tf "\"(?<after_quote_stuff>.*)"
0 Karma

jplumsdaine22
Influencer

Escape it with a . EG if you have foo="bar and you want to extract bar

| rex field=foo "\"(?<bar>[A-z]+)"
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...