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
Super Champion

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
Super Champion

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
Super Champion

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

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...