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
Get Updates on the Splunk Community!

Security Professional: Sharpen Your Defenses with These .conf25 Sessions

Sooooooooooo, guess what. .conf25 is almost here, and if you're on the Security Learning Path, this is your ...

First Steps with Splunk SOAR

Our first step was to gather a list of the playbooks we wanted and to sort them by priority.  Once this list ...

How To Build a Self-Service Observability Practice with Splunk Observability Cloud

If you’ve read our previous post on self-service observability, you already know what it is and why it ...