Splunk Search

Trying to combine two regexes into one

thepocketwade
Path Finder

I'm trying to throw out search results from a couple of different ip ranges. Currently I'm working with 2, but I might end up with three or more. Anywhoo, regex A looks like "XY.\d{1,3}.\d{1,3}.\d{1,3}" and regex B looks like "XYZ.AB.\d{1,3}.\d{1,3}"

I want one regex to match both. I thought that doing "XY.\d{1,3}.\d{1,3}.\d{1,3}|XYZ.AB.\d{1,3}.\d{1,3}" would do it, but it's not.

I've not had much luck finding help online, maybe you guys can help?

Tags (1)
1 Solution

BunnyHop
Contributor

Try this:

(XY.\d{1,3}|XYZ.AB).\d{1,3}.\d{1,3}

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

You may also want to look using into the where command with the cidrmatch() function:

http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/CommonEvalFunctions

BunnyHop
Contributor

There's also something I noticed if you're performing the search on SplunkWEB, the search tends to become slow when you're searching regex from raw log files, than searching indexed fields.

0 Karma

BunnyHop
Contributor

Try this:

(XY.\d{1,3}|XYZ.AB).\d{1,3}.\d{1,3}

thepocketwade
Path Finder

thanks, that did the trick.

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

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