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!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...