Splunk Search

Combine two regular expressions into one

dangerdx
New Member

I want to combine two regular expressions.Please help me.

\b(2013)[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])\b


[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}:(?:[a-zA-Z0-9]{5,})

Thanx.

0 Karma

kristian_kolb
Ultra Champion

As has been suggested, some sample events would be good. Also, a clearer description of your use case would be nice, i.e. what do you want to achieve. From your comments above one could think that you want to search for events ranging between certain dates and extract the email addresses out of that.

Assuming that the '2013' part of the date you want to filter on, is part of the actual timestamp that splunk used for indexing your events, you can use the built-in time modifiers for searching;

index=blah earliest=-1y@y latest=@y | rex "\s(?<email>\S+@\S+)"

The regex used for extracting the email field in the example above is also quite simplified, mut may well work for you (depending on the contents of your events).

So, provide sample events and a clearer description of your desired outcome, and you'll get better help.

/K

0 Karma

dangerdx
New Member

@martin yes i want to commbine into AB.
That's what i am asking how should i do it?

@rsennett actually its a regex expression for email combos and date of only 2013 like 2013/9/24 or 2013/10/22.I want to combine both so that i could capture only 2013 email combos.Is it possible?

0 Karma

rsennett_splunk
Splunk Employee
Splunk Employee

Also... if this is Splunk related you might want to share what you are trying to capture (give us a sample) and to what end you are wanting to combine the regex. Without knowing what you are trying to do, there is no way to help...

With Splunk... the answer is always "YES!". It just might require more regex than you're prepared for!
0 Karma

lguinn2
Legend

What are you trying to do in Splunk? If this isn't Splunk-related, I suggest that you take the question to http://stackoverflow.com/

martin_mueller
SplunkTrust
SplunkTrust

Okay, so you have regular expressions A and B, and "combine" them into regular expression AB.

How should AB behave?

0 Karma

dangerdx
New Member

it means write two into one.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

What do you mean by "combine"?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

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

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...