Splunk Search

'How do I use regex in Splunk to pull out numbers and decimals and not letters;?

ESPrioleau
New Member

For instance: the results have 01.2.3 and ABC5. How do I only pull out 01.2.3?

Tags (2)
0 Karma

jpolvino
Builder

Sounds like you're looking for something that matches "starts with a number, followed by 1 or more numbers and periods." If so, then this might work:

| rex "^\d[\d\.]+"

If the string you're trying to extract is part of a larger field value, then:

| rex ".*(?<token>\d[\d\.]+)"

If you have an event with and without the text you are trying to extract, please post it. Often, the text before and after what you're trying to extract can help make the rex more accurate.

0 Karma

somesoni2
Revered Legend

Assuming you want to filter results if a field value contains one or more alphanumeric character (and keep the one with numbers and decimal), then try something like this:

your current search
| regex fieldName!=".+[A-z].+"
0 Karma

solarboyz1
Builder

The following regex :

| rex "(?<new_fieldname>\d+\.\d+\.\d+)"

Should produce new_fieldname=01.2.3

\d -> only matches number characters
\. -> matches a literal period (.)

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...