Reporting

Regex to extract quoted text aftera stats command

cindygibbs_08
Communicator

I hope everyone is having a great time today,
I am here to first thank you guys for being so helpful and assertive! you people rock! and second to ask for assistance regarding a regular expression.
I have a field that will contain a string that will start by "check-in unavailable due to external cause the ref code is ##AIUI- 989 K-IOJ##"
I want to be able to extract the string that is between the "##"  but... sometimes this field may have a string that starts by "the auth was..." I want to be able to extract any string   between two "#" whenever the value of the field starts with  "check-in unavailable due to external cause the ref code is"  

 

for example
 if I have this:

FIELDCODE
"check-in unavailable due to external cause the ref code is ##AIUI- 989 K-IOJ##AIUI- 989 K-IOJ
"the auth was denied code ## uik-55855##"N.A

 

thank you guys SO MUCH

 

Kindy,

Cindy

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults 
| eval _raw="check-in unavailable due to external cause the ref code is ##AIUI- 989 K-IOJ##
the auth was denied code ## uik-55855##"
| multikv noheader=t
| fields _raw
| rex "check-in unavailable due to external cause the ref code is ##(?<code>[^#]+)##"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults 
| eval _raw="check-in unavailable due to external cause the ref code is ##AIUI- 989 K-IOJ##
the auth was denied code ## uik-55855##"
| multikv noheader=t
| fields _raw
| rex "check-in unavailable due to external cause the ref code is ##(?<code>[^#]+)##"

cindygibbs_08
Communicator

I have a question what would the rex function will look like if instead of two "#" the coude would come inside two "*"  like this :  **UID J- DIDD**, I would just change the "#" by "*"??

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Asterisks "*" have special meaning in regex so each would need to be escaped with a backslash "\"

| makeresults 
| eval _raw="check-in unavailable due to external cause the ref code is **AIUI- 989 K-IOJ**
the auth was denied code ** uik-55855**"
| multikv noheader=t
| fields _raw
| rex "check-in unavailable due to external cause the ref code is \*\*(?<code>[^\*]+)\*\*"

 

0 Karma

cindygibbs_08
Communicator

@ITWhisperer  I am in love with you

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Thanks Cindy ❤️😁

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...