Splunk Search

How to use Regex to find values between two strings

hartfoml
Motivator

I have this event:

<f:Table><f:Row><f:Cell>IE Group Policy</f:Cell></f:Row><f:Row><f:Cell>HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\SecureProtocols</f:Cell></f:Row><f:Row><f:Cell>Windows SChannel</f:Cell></f:Row><f:Row><f:Cell>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client\Enabled</f:Cell></f:Row><f:Row><f:Cell>IE</f:Cell></f:Row><f:Row><f:Cell>HKEY_USERS\Software\Microsoft\Windows\CurrentVersion\Internet Settings\SecureProtocols</f:Cell></f:Row><f:Row><f:Cell>KB3009008</f:Cell></f:Row></f:Table> 

and I have other events like this. I want to extract the information between the <f:Cell></f:Cell> in this event, there are several entries, but in most, there is only one entry. How can I get this to work in all cases?

Help With Regex Please

0 Karma
1 Solution

sundareshr
Legend

Try this

... | rex max_match=0 "\<f\:Cell\>(?<cellvalue>[^\<]+)\<\/f\:Cell\>" | table cellvalue | mvexpand cellvalue | ...

View solution in original post

0 Karma

sundareshr
Legend

Try this

... | rex max_match=0 "\<f\:Cell\>(?<cellvalue>[^\<]+)\<\/f\:Cell\>" | table cellvalue | mvexpand cellvalue | ...
0 Karma

maheshkk444
Loves-to-Learn Everything

There is single events which contains multiple conversationid:"conv_abc" workgroup, conversations:"conv_xyz" workgroup. I have to find all values between conversationid and workgroup which are in single event. I had tries one Rex but it giving content between first conversationid and last workgroup string

0 Karma

hartfoml
Motivator

Thanks this works great

0 Karma

skoelpin
SplunkTrust
SplunkTrust

Here ya go..

(?<=\<f\:Cell\>).*(?=\<\/f\:Cell\>)

If you're doing it at index time then it will look like this (?P<FieldName>(?<=\<f\:Cell\>).*(?=\<\/f\:Cell\>))

This uses a lookbehind to sink into and a lookahead to sink into <\f:Cell>

0 Karma
Get Updates on the Splunk Community!

Cultivate Your Career Growth with Fresh Splunk Training

Growth doesn’t just happen—it’s nurtured. Like tending a garden, developing your Splunk skills takes the right ...

Introducing a Smarter Way to Discover Apps on Splunkbase

We’re excited to announce the launch of a foundational enhancement to Splunkbase: App Tiering.  Because we’ve ...

How to Send Splunk Observability Alerts to Webex teams in Minutes

As a Developer Evangelist at Splunk, my team and I are constantly tinkering with technology to explore its ...