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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...