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!

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...

Stay Connected: Your Guide to July Tech Talks, Office Hours, and Webinars!

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...