Splunk Search

rex Named extraction for acronyms that have 4 letters and are all capital letters

agoktas
Communicator

Hello,

I'm trying to create a named extraction and want to use regex to find all instance of 4 letter acronyms that are all capitol letters.

i.e.: ABCD, DEFG, HIJK, LMNO.

Needs to find only 4 consecution letters that are all CAPS.

Anyone able to provide an example for the syntax I need?

Thanks!

Tags (1)
0 Karma
1 Solution

javiergn
SplunkTrust
SplunkTrust

The regex you need is just the following

[A-Z]{4}

In terms of the named extraction you are talking about it all depends where you want to do this.
If you are happy to do it in SPL simply use rex:

your query here
| rex field=YOUR_FIELD_WITH_ACRONMYS "(?<named_field>[A-Z]{4})"

Which will create a new field called "named_field".

If you are expecting more than 1 match in a single event then use max_match=0 in your rex command. It'll then create "named_field" as a multivalue field.

If you want to do this in props.conf and/or transforms.conf I would recommend you read the following doc as again, it all depends on your use case and I don't have enough information to give you a decent advice:

http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Createandmaintainsearch-timefieldextrac...

EXAMPLES
This might be the simplest one of all in props.conf:

EXTRACT-acronyms = (?<named_field>[A-Z]{4})

If you wanted that multivalue you could use REPORT in props.conf and then elaborate the extraction in transforms.conf:

# props.conf
[your_sourcetype]
REPORT-acronyms = mv_acronyms

# transforms.conf
[mv_acronyms]
REGEX = (?<named_field>[A-Z]{4})
MV_ADD = true

Hope that helps as a start,
J

View solution in original post

0 Karma

javiergn
SplunkTrust
SplunkTrust

The regex you need is just the following

[A-Z]{4}

In terms of the named extraction you are talking about it all depends where you want to do this.
If you are happy to do it in SPL simply use rex:

your query here
| rex field=YOUR_FIELD_WITH_ACRONMYS "(?<named_field>[A-Z]{4})"

Which will create a new field called "named_field".

If you are expecting more than 1 match in a single event then use max_match=0 in your rex command. It'll then create "named_field" as a multivalue field.

If you want to do this in props.conf and/or transforms.conf I would recommend you read the following doc as again, it all depends on your use case and I don't have enough information to give you a decent advice:

http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Createandmaintainsearch-timefieldextrac...

EXAMPLES
This might be the simplest one of all in props.conf:

EXTRACT-acronyms = (?<named_field>[A-Z]{4})

If you wanted that multivalue you could use REPORT in props.conf and then elaborate the extraction in transforms.conf:

# props.conf
[your_sourcetype]
REPORT-acronyms = mv_acronyms

# transforms.conf
[mv_acronyms]
REGEX = (?<named_field>[A-Z]{4})
MV_ADD = true

Hope that helps as a start,
J

0 Karma

javiergn
SplunkTrust
SplunkTrust

@agoktas please do not forget to accept an answer if you are happy with it

0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...