Splunk Search

Regex for fields

shugup2923
Path Finder

Hi All,
can you please help in extracting three fields from below data using regex
Name code Type

Below are three different type of values , out of which I need to extract Name code Type

Name-1453-Users@company------- after extraction(Name=Name code=1453 Type=User)
Name-ROR444-Users@company------- after extraction(Name=Name code=ROR444 Type=User)
Name-Name-ROR444-Users@company-------- after extraction(Name=Name-Name code=ROR444 Type=User)
Name-Name-Name-Name-1435-Users@company-------- after extraction ( Name=Name-Name-Name-Name code=1435 Type=User)

Tags (1)
0 Karma
1 Solution

ololdach
Builder

Hi,
rex field=_raw "^(?<Name>.*)-(?<code>\w+|\d+)-\w+@" | eval Type="User"

View solution in original post

0 Karma

ololdach
Builder

Hi,
rex field=_raw "^(?<Name>.*)-(?<code>\w+|\d+)-\w+@" | eval Type="User"

0 Karma

shugup2923
Path Finder

We can't use Eval to create Type as it could be approver also

0 Karma

shugup2923
Path Finder

Thannks for your help-
Final Regex
^(?.*)-(?\w+|\d+)-(?\w+)\@

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 ...