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!

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Customers Increasingly Choose Splunk for Observability

For the second year in a row, Splunk was recognized as a Leader in the 2024 Gartner® Magic Quadrant™ for ...