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
Esteemed Legend

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
Esteemed Legend

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

Get Updates on the Splunk Community!

Admin Your Splunk Cloud, Your Way

Join us to maximize different techniques to best tune Splunk Cloud. In this Tech Enablement, you will get ...

Cloud Platform | Discontinuing support for TLS version 1.0 and 1.1

Overview Transport Layer Security (TLS) is a security communications protocol that lets two computers, ...

New Customer Testimonials

Enterprises of all sizes and across different industries are accelerating cloud adoption by migrating ...