Splunk Search

Is there a better way to edit my regular expression?

Accak
Path Finder

Hey guys,
I have field with values like:

RQT4 - Ownership foo barr
R11: Assistance fooo barr 192392
RQR11 -RFI A lot of text and digits

I want to cut the beginning with RQR/R/RQT, "/", ":" and whitespaces

My search (working on regex101.com)

| rex field=fieldToExtract mode=sed "s/^(RQT|RQR|R|r)\d+(\s\W\s|\s\W|\W\s|\W|\s)//"  | 

And still its not working for all values, f.e

RQT11 - Apply remove CMS
RQT2 - Library creation - (1)
R11 - Apply RAW
RQR3 - RDI Remove

Any ideas why?
I bet there is better way to do it. For example Cut all before first 3 word characters which are not RQR or RQT, or R\d\d.
Thanks in advance!

0 Karma
1 Solution

Accak
Path Finder

I just added "g" on the end and it's workig.

| rex field=fieldToExtractmode=sed "s/^R\w+\d+\W+//g"|

But still don't know what "g" acctualy make.

View solution in original post

0 Karma

Accak
Path Finder

I just added "g" on the end and it's workig.

| rex field=fieldToExtractmode=sed "s/^R\w+\d+\W+//g"|

But still don't know what "g" acctualy make.

0 Karma

Accak
Path Finder

Thanks Accak

0 Karma

Accak
Path Finder

You are welocme Accak

0 Karma

woodcock
Esteemed Legend

g is for global meaning it will repeat the same command over and over until it gets to the end of the string and cannot match any more.

Accak
Path Finder

I managed to short it :

| rex field=fieldToExtract mode=sed "s/^(R|r)\w+\d+\W+//" |

But still the same values stay unchanged.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...