Getting Data In

How to use a combination of multiple regex cindition in transforms.conf

hyugma
Explorer

Hi Expert,
I am trying to confiture transforms that has multiple condition for match, with the following condition:

 

 

(word1 OR word2) AND word3 NOT ('phrase 4' OR 'phase 5')

 

 

and I tried the following config, but still no luck.

 

 

[source::.../input.log]
REGEX =^(?=.*(word1|word2))(?=.*word3)(?!.*(phrase 4|phrase 5)).*$
FORMAT = sourcetype::mytype
DEST_KEY = MetaData:Sourcetype

 

 

The regex may be wrong or there is another workaround to archive this... 
Any comment and/or recommendation would be really appreciated..

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

IME, anchors aren't needed that often and it's a rare case that needs both ^ and $ anchors.

Have you used regex101.com to test your regular expression against samples of your data?

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

IME, anchors aren't needed that often and it's a rare case that needs both ^ and $ anchors.

Have you used regex101.com to test your regular expression against samples of your data?

---
If this reply helps you, Karma would be appreciated.
0 Karma

hyugma
Explorer

Thank you for the comment. 

You are right, I would not need many anchors everywhere.
and I could confirm that the regex with AND and OR mixed worked.

Thank you, @richgalloway 

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