Splunk Enterprise

Regex to parse a string with commas

asdfxqwert
Explorer

I have a field with values like below

(a)

(a,b)

(c)

(a,c)

 

I am trying to parse these values, and get stats like below 

 

a 3

b 1

c 2

0 Karma
1 Solution

isoutamo
SplunkTrust
SplunkTrust

Hi

you can try this

| makeresults 
| eval _raw="F1
(a)
(a,b)
(c)
(a,c)"
| multikv forceheader=1
```Above generates sample data```
| rex mode=sed field=F1 "s/[\(\)]//g"
| makemv delim="," F1
| mvexpand F1
| stats count by F1

r. Ismo 

View solution in original post

isoutamo
SplunkTrust
SplunkTrust

Hi

you can try this

| makeresults 
| eval _raw="F1
(a)
(a,b)
(c)
(a,c)"
| multikv forceheader=1
```Above generates sample data```
| rex mode=sed field=F1 "s/[\(\)]//g"
| makemv delim="," F1
| mvexpand F1
| stats count by F1

r. Ismo 

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Unmerging HTML Tables

[Puzzles] Solve, Learn, Repeat: Unmerging HTML TablesFor a previous puzzle, I needed some sample data, and ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...

AI for AppInspect

We’re excited to announce two new updates to AppInspect designed to save you time and make the app approval ...