Splunk Search

How to rex extract from text that starts with a newline and ends with a newline?

spencerneal
Explorer

Hello, 

I am trying to figure out how to rex extract from text that starts with a newline and ends with a newline.  For example:  \\nCAR PRODUCT: bat mobile\n

Does anyone know a good way around this situation so that only "bat mobile" is extracted?

 

Thank you for your help.

Spencer

Labels (1)
0 Karma

spencerneal
Explorer

Giuseppe,

Thank you for your help.

I am trying to rex extract "bat mobile" from something similar to the following raw text.

As you can see there is a newline following "bat mobile".  I am having trouble figuring out how to rex "bat mobile" only and not get everything after "bat mobile". 

example:  \\nDAMAGED PRODUCT: bat mobile\nmail:sneal@gmail.com

my current code is:  

|rex “DAMAGED PRODUCT:  (?P<SWN>.+?)"

However, I don't know what to put after the second parentheses so that rex will only extract "bat mobile".

I hope my thought makes sense.

Once again, thank you greatly for your help.

Spencer

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @spencerneal,

as I said, the only way I can help you is that you share some samples (not one!) of your logs: eventually mask sensible contents but don't change the log structure.

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @spencerneal,

the request is just a little vague because if in your events you have more lines, you'll have more extractions, is this what you want?

Otherwise please give more details in extraction and, please, share some sample of your data highlighting the parts to extract.

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

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 ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...