Splunk Search

Simplify REGEX

CarbonCriterium
Path Finder

Several months back I created a macro with the following regular expressions to "clean up" and concatenate several strings that I  often use.  Is there a website or tool that would help me to understand regex so that I may figure out how to simplify the search string? 

My goal is to speed up the search.  I think eliminating the redundant rex commands would help but if there is an even better solution I want to know what it is.

The macro currently contains the following:

 

| eval source_clean=source 
| rex field=source_clean mode=sed "s/\\\u_\S+//g" 
| rex field=source_clean mode=sed "s/^[^\\\]*\\\//" 
| rex field=source_clean mode=sed "s/^[^\\\]*\\\//" 
| rex field=source_clean mode=sed "s/^[^\\\]*\\\//" 
| lookup Source-Lookup.csv source AS source_clean OUTPUT web_domain 
| eval pages = web_domain+cs_uri_stem​​​​​​​

 

 
I do not have access to the lookup table that would allow me to add slashes to the `source column` as a way to eliminate the need for lines 3-5.  

Labels (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @CarbonCriterium,

regex101.com is very useful to understand a regex, but to simplify your regex you have to work by yourself or sharing samples.

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @CarbonCriterium,

regex101.com is very useful to understand a regex, but to simplify your regex you have to work by yourself or sharing samples.

Ciao.

Giuseppe

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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...