Splunk Search

How to extract the nth letter from these sample host names using regular expression?

imthesplunker
Path Finder

How to extract the nth letter from the host using regular expression?

Sample hosts are :-
host=abcdefpghijkl11 (prod )
host=abcdefsghijkl12 (stg)
host=abcdefdghijkl13 (dev)

0 Karma
1 Solution

somesoni2
Revered Legend

Try like this. e.g. if you want to extract 10th character,

your base search | eval mychar=substr(host,10,1)

Alternatively,

your base search | rex field=host "^\w{9)(?<mychar>\w)"

View solution in original post

0 Karma

somesoni2
Revered Legend

Try like this. e.g. if you want to extract 10th character,

your base search | eval mychar=substr(host,10,1)

Alternatively,

your base search | rex field=host "^\w{9)(?<mychar>\w)"
0 Karma

imthesplunker
Path Finder

Thanks !...

0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

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