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

Did you miss .conf21 Virtual?

Good news! The event's keynotes and many of its breakout sessions are now available online, and still totally FREE!