Splunk Search

Extract multiple words in a filed

marco_massari11
Communicator

Hi,

I have some syslog logs and I need to extract the first words of a field values. The field value starts like this:

Site Corporate Windows AM\\Passed\\     

My result should be :       

Corporate Passed

Note: I can have also Unmanaged instead of Corporate and Failed insted of Passed, so I have 4 options:

Corporate Passed

Corporate Failed

Unmanaged Passed

Unmanaged Failed         

Labels (4)
0 Karma
1 Solution

nickhills
Ultra Champion

That happens because of some additional escaping which is needed.

 

Try this version, which avoids needing a triple \ 

 

Site (?<site>\w+).+\\\\(?<result>\w+)

 

If my comment helps, please give it a thumbs up!

View solution in original post

0 Karma

493669
Super Champion

@marco_massari11 if you want extract multiple fields then try below-
Updated-

 

Site (?<field1>\w+)[^\\\\]+\\\\(?<field2>\w+)

 

It will extract in field1 and field2.



-------
let me know if it helps! 

0 Karma

marco_massari11
Communicator

Hi @493669  I have this message error  Regex: missing terminating ] for character class. 

0 Karma

nickhills
Ultra Champion

That happens because of some additional escaping which is needed.

 

Try this version, which avoids needing a triple \ 

 

Site (?<site>\w+).+\\\\(?<result>\w+)

 

If my comment helps, please give it a thumbs up!
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...