Splunk Search

Regex formating help

AHEARNJ
Explorer

Can anyone help me format a regular expression for Splunk?
I can create the regular expression using regexr.com and I have 2 non-capturing groups and a capturing group, but I am not sure how to format the regular expression for splunk.
Any tips or help you can provide is appreciated.

Here is my string:
string1="First Name (DEPT-User) account provisioned"
And the regex:
(:?string1=")([A-Za-z0-9() -]+)(:?account provisioned")
Thanks,

0 Karma
1 Solution

niketn
Legend

Does your data contain string1="First Name (DEPT-User) account provisioned"? Ideally Splunk should have automatically identified this as key value pair during search time. Which implies you would need to create field extraction/rex on string1. Have you checked Interesting Fields in Verbose mode whether string1 field is already available or not? Which is the field you want to extract?

If you want to extract First Name (DEPT-User), following rex should work:

<YourBaseSearch> 
| rex field=_raw "string1=\"(?<Data>[^\)]+\)) account provisioned\""
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

Does your data contain string1="First Name (DEPT-User) account provisioned"? Ideally Splunk should have automatically identified this as key value pair during search time. Which implies you would need to create field extraction/rex on string1. Have you checked Interesting Fields in Verbose mode whether string1 field is already available or not? Which is the field you want to extract?

If you want to extract First Name (DEPT-User), following rex should work:

<YourBaseSearch> 
| rex field=_raw "string1=\"(?<Data>[^\)]+\)) account provisioned\""
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

niketn
Legend

@AHEARNJ, I have converted comment to answer. Please accept to mark as answered!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
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 ...