Splunk Search

Simple regex

clymbouris
Path Finder

I'm just trying to get the CN name from what looks like the fields below
CN=John Smith,OU=Customer Service,OU=Users,OU=UK,DC=COMPANY,DC=LOCAL
CN=John Jr. Smith,OU=VIPs,OU=UK,DC=COMPANY,DC=LOCAL

I tried this

rex field=Name "CN=(?<Name>*),OU=" 

but didn't work out cause it kind of matches the last OU= instead of the first..

Tags (1)
0 Karma
1 Solution

alacercogitatus
SplunkTrust
SplunkTrust

I think a slightly more accurate regex would be CN=(?<cn>[^,]*), as this will capture any CNs within a CN, and not just OUs. It will also capture any CNs that have an O or U in them.

View solution in original post

alacercogitatus
SplunkTrust
SplunkTrust

I think a slightly more accurate regex would be CN=(?<cn>[^,]*), as this will capture any CNs within a CN, and not just OUs. It will also capture any CNs that have an O or U in them.

sbrant_splunk
Splunk Employee
Splunk Employee

try this one:

CN=(?<Name>[^OU]*),OU
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...