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!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...