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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...