Splunk Search

How to remove leading periods from a field?

ajdyer2000
Path Finder

Hi I have a search that returns the following

. Adobe Acrobat XI Pro DSC

.. Adobe Flash Player ActiveX DSC
... Adobe Flash Player NPAPI
... Adobe Reader XI (..)
.. Adobe Shockwave Player
... Atmel Touchscreen Power

Is there a command that could get rid of the leading periods? They go from just one period up to three of them

0 Karma

gokadroid
Motivator

Try this please using rex assuming your fieild is called myField and data of interest will be collected in field called stringOfInterest :

your query to return events
| rex field=myField "\.+(?<stringOfInterest>.*)"
| table stringOfInterest

See Extraction here

0 Karma

jtacy
Builder

Sure, here's a standalone example of what you could do with the rex command:

| gentimes start=-1 | eval xyzzy=".. Adobe Shockwave Player" | rex field=xyzzy mode=sed "s/^\.+(\s+)?//"

This will remove any leading periods and whitespace after the periods. There are probably faster ways to do it but this should work pretty well. Good luck!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...