Splunk Search

Regex Help

bcanfield83
Engager

Hello,

I'm attempting to use the regex command to filter out any records on the "user" field that do not match the written expression below:

index=myindex sourcetype=traceability_log4net earliest=-10d 
| regex _raw="user=[a-z]{3,6}[a-z1-9]{1,2}" 
| table user

Per the expression, there should not be any "user" records that exceed 8 characters. However, the non-matching values are not being filtered out.

"sstevenson6111", for example,  should theoretically be listed as "sstevens" per the expression.

regex_user-table.PNG

 I'm sure there's something blindingly obvious that I'm missing! 😳

 

Labels (1)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Your regex is matching against the _raw field. It it looking for a string in the _raw field which could be anywhere in the _raw field matching the expression user=[a-z]{3,6}[a-z1-9]{1,2} , for example:

notuser=abc1@nowhere

user=sstevenson6111

All your examples match this expression

richgalloway
SplunkTrust
SplunkTrust

The regex command passes what matches the specified expression.  To filter them out, use !=.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...