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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...