Splunk Search

How to merge two regex in single query?

Rakzskull
Path Finder

I'd want to merge two regex strings into a single one; any suggestions would be greatly appreciated.

Reference Search Query -

index=* sourcetype=XYZ "<ABC2>" "<ABC1>"

| regex _raw="<ABC1>[^\x00-\x7F]"
| regex _raw="<ABC2>[^\x00-\x7F]"

Thanks in advance. 🙂

 

Labels (4)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If you know the order of ABC1 and ABC2 and you only want events where both start with a character outside the range then you could try

index=* sourcetype=XYZ "<ABC2>" "<ABC1>"

| regex _raw="<ABC1>[^\x00-\x7F].+<ABC2>[^\x00-\x7F]"

If you need either order, you could try

index=* sourcetype=XYZ "<ABC2>" "<ABC1>"

| regex _raw="(<ABC1>[^\x00-\x7F].+<ABC2>[^\x00-\x7F]|<ABC2>[^\x00-\x7F].+<ABC1>[^\x00-\x7F])"

 Or if you want events where either start with a character outside the range

index=* sourcetype=XYZ "<ABC2>" "<ABC1>"

| regex _raw="(<ABC1>[^\x00-\x7F]|<ABC2>[^\x00-\x7F])"
0 Karma

PaulPanther
Motivator

Hello Rakzskull,

you can just combine two regex strings into one like everywhere else.

Easy example in your internal data would be 

index=_internal | regex _raw="^(\d{2,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s-\s(splunk-system-user)"

 If it does not work like expected please provide some example data and your regex strings.

Thank you!

0 Karma
Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

New Release | Splunk Cloud Platform 10.1.2507

Hello Splunk Community!We are thrilled to announce the General Availability of Splunk Cloud Platform 10.1.2507 ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

&#x1f5e3; You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...