Splunk Search

Regex Help!

NShimmen
New Member

Hi!

First time I am attempting Regex commands and I have got pretty stuck so any help would be much appreciated. I have a string data that appears in a table as "Network User::(FirstName).(Surname)".

How could I use the regex command to get rid of Network User and just display the first and second name in the results table?

So my search would be something like:

...| stats count by user|regex......| table user, count

Thanks!

Tags (2)
0 Karma

p_gurav
Champion

Can you try something:

...| stats count by user| rex field=user mode=sed "s/Network User::*//g" | table user, count
0 Karma

TISKAR
Builder

Hello,
Try this:

.| stats count by user | rex field=a "::\((?<FirstName>[^.)]*)\)\.\((?<Surname>[^.)]*)"

For Example:

| makeresults |eval a= "Network User::(FirstName).(Surname)" | rex field=a "::\((?<FirstName>[^.)]*)\)\.\((?<Surname>[^.)]*)"
0 Karma

damien_chillet
Builder

An example of regex extraction that would work with the example string you provided:

| rex field=user "::\((?P<first_name>[^\)]+)\)\.\((?P<surname>[^\)]+)\)"
0 Karma

David_Naylor
Path Finder

Try to get those field extractions done. You can do it inline with the following
|rex "Network\sUser::(?P\w+)).((?P\w+)) | table FirstName,Surname,count

0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...