Splunk Search

Help with regex needed

damucka
Builder

Hello,

I am trying to extract the system IDs from single event into the multiple events, I mean that each SID is in a separate line. I try to deploy a regex for this, without success.

Could perhaps anyone help with the below?

Kind Regards,

Kamil

 

| makeresults
| eval 
SID="I32
DYR
DZ1
MHW
DYN
I58
ICZ
ICN
I69
I8Y
IAE
I6J
I71
SLG
I9Z
I7T
I7Z
I5Y
I5U
I5T
I3I
I3G
TCX
I5O
DZX
DZC
DYQ
DYO
DYM
OGO
OJ8
OK8
OKQ
OKX
DXF
DYE
DYF
SS4
QMW
I24
R9H
O67
OP0
SP9
I4I
I4M"

| rex field=SID "^(?<SID2>[^\r\n].+)"

 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

By default, the rex command returns a single match.  Use the max_match option to change that.  Then use the mvexpand command to split the field into separate events.

 

| rex field=SID max_match=0 "(?<SID2>.+[^\S]+)"
| mvexpand SID2

 

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

By default, the rex command returns a single match.  Use the max_match option to change that.  Then use the mvexpand command to split the field into separate events.

 

| rex field=SID max_match=0 "(?<SID2>.+[^\S]+)"
| mvexpand SID2

 

 

---
If this reply helps you, Karma would be appreciated.

damucka
Builder

Unfortunately this solution does not work, still getting just the first match only

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I modified the regex.  Please try the revised query.

---
If this reply helps you, Karma would be appreciated.
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!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...