Splunk Search

How to use rex to remove "domain\' from a username?

pil321
Communicator

I have a field that looks like this:

UserName=domain\joe_user

I want it to look like this:

UserName=joe_user

How do I take out domain\ using rex?

0 Karma
1 Solution

somesoni2
Revered Legend

Try this

your base search | rex field=UserName "\w+\\(?<UserName>.*)"

OR

your base search | eval UserName=mvindex(split(UserName,"\\"),-1)

View solution in original post

Dev_Choudhary
Path Finder

try this

rex field=cs_userdn "\w+\\(?\S+)"

0 Karma

woodcock
Esteemed Legend

Like this:

... | rex field=UserName mode=sed "s/[^\\\]*\\\//"
0 Karma

somesoni2
Revered Legend

Try this

your base search | rex field=UserName "\w+\\(?<UserName>.*)"

OR

your base search | eval UserName=mvindex(split(UserName,"\\"),-1)
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...