Splunk Search

Could you help me use rex to extract end value extensions from field values?

arrangineni
Path Finder

I have field values with the below formats and I need to extract the end value extensions like (cjs, js ..,etc) from them and store them in separate fields. Can anyone help me with this? Thanks

sample=/abc/test/ipts/jquery-1.3.1-vsdoc.cjs 
sample=/abc/test/ipts/jquery-1.3.js
0 Karma

ddrillic
Ultra Champion
0 Karma

osakachan
Communicator

Hello,

try this one:

".*\.(?.*)$"

Tested with:
| makeresults |eval lol="/abc/test/ipts/jquery-1.3.1-vsdoc.cjs " | rex field=lol ".*\.(?<foo>.*)$" | table lol,foo

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi arrangineni,
try something like this:

\.(?<extension>.*)$

if you already extracted the field sample, you could also use the command

| rex field=sample "\.(?<extension>.*)$"

You can test it at https://regex101.com/r/L5vehV/1

Bye.
Giuseppe

0 Karma

kmorris_splunk
Splunk Employee
Splunk Employee

This is probably a bit greedy, but it works in regex101.com:

.*\.(?<extension>[a-z]+)

cpetterborg
SplunkTrust
SplunkTrust

So do you want the js and cjs values from the sample field stored in a separate field (like one named ext) at search time?

0 Karma
Get Updates on the Splunk Community!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...