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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...