Splunk Search

How to edit my regular expression to extract values from a logfile that begin with "FNR" and are 10 alphanumeric characters long?

Lucas_Henry_
New Member

I'm trying to use a regular expression to grab words out of a logfile that begin with "FNR" and are exactly 10 alphanumeric characters long, and save that to a new field called ErrorCode.

The expression I've written in a PCRE generator doesn't seem to work with Splunk. It's below:

(^|)FNR.......(|$)(?P)

How do I make it work with Splunk?

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Is that 10 characters including "FNR" or after?

Try this regex (?<ErrorCode>FNR\w{7}).

BTW, www.regex101.com seems to do a good job of validating regular expressions Splunk will handle.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Is that 10 characters including "FNR" or after?

Try this regex (?<ErrorCode>FNR\w{7}).

BTW, www.regex101.com seems to do a good job of validating regular expressions Splunk will handle.

---
If this reply helps you, Karma would be appreciated.

Lucas_Henry_
New Member

Works perfectly. thank you my friend

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, ...