Splunk Search

How to extract a string using regex?

AbubakarShahid
New Member

Hello all,

I am trying to write a regex to extract a string out an interesting field that I have already created and wanted to extract a string out by using regex.
I created a table that displays 4 different columns and from one of the column, I want to extract out "Message accepted for delivery" and put it into a new column. is there a way to do that. Much appreciate it.

0 Karma
1 Solution

damiensurat
Contributor

You sure can. But before I get into it, here's a site that can help with your regex expression extractions:
https://regex101.com/
It would be better if you supplied the whole string in the field containing "Message accepted for delivery", as well as your search, as I can better answer this question with those provided, but this rex should do the trick:

yoursearch | rex field=fieldContainingYourMessage "(?<Message1>Message accepted for delivery)"

What the search above will do will provide you with a new field called Message1 and the content/values will be "Message accepted for delivery"

View solution in original post

0 Karma

damiensurat
Contributor

You sure can. But before I get into it, here's a site that can help with your regex expression extractions:
https://regex101.com/
It would be better if you supplied the whole string in the field containing "Message accepted for delivery", as well as your search, as I can better answer this question with those provided, but this rex should do the trick:

yoursearch | rex field=fieldContainingYourMessage "(?<Message1>Message accepted for delivery)"

What the search above will do will provide you with a new field called Message1 and the content/values will be "Message accepted for delivery"

0 Karma

skoelpin
SplunkTrust
SplunkTrust

We can't help until there is sample data to test against

0 Karma

tiagofbmm
Influencer

Can you show us one sample line of your table and tell us exactly what you want to extract please?

0 Karma
Get Updates on the Splunk Community!

Enhance Your Splunk App Development: New Tools & Support

UCC FrameworkAdd-on Builder has been around for quite some time. It helps build Splunk apps faster, but it ...

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...