Dashboards & Visualizations

Remove everything before backslash in string?

Nomarja
Engager

I am trying to remove some unwanted characters before the backslash, but it is ignoring some machines as they have different name standards.

I want to remove the domain name and machine name from the Local Administrator group.

 My data comes like this in one string as below

labmachine000r\administrator labmachine000d\support  labdomain\admingroup labdomain\helpdesk

I managed to remove the characters before the backslash using this

 

| eval adminlocal=replace(adminlocal, "\w+(\\\\)+","")

 

and my result is like below:

administrator support  admingroup helpdesk

That is working fine for the machine above, but if I have a machine name like "L-02labmachine000r", the replace command gives the result like this:

L-administrator L-support admingroup helpdesk

Is there any way to adjust my replace command to cover that machine name?

 

 

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

Gr0und_Z3r0
Contributor

Something like this....

| makeresults
| eval adminlocal = "labmachine000r\administrator labmachine000d\support labdomain\admingroup labdomain\helpdesk"
| eval adminlocal=replace(adminlocal, "\w+(\\\\)+","")
| eval mc = "L-02labmachine000r\administrator L-02labmachine000r\support L-02labmachine000r\admingroup L-02labmachine000r\helpdesk labdomain\admingroup labdomain\helpdesk L-99labmachine000r\admingroup L-0216labmachine000r\helpdesk"
| eval new_mc=replace(mc,"[\w\d\-]+(\\\)+","")

Gr0und_Z3r0_0-1637843842052.png

 

Please upvote if it helps.

View solution in original post

Nomarja
Engager

Thanks @Gr0und_Z3r0 , that did the trick. I appreciate your help

0 Karma

Gr0und_Z3r0
Contributor

Cheers mate. Happy Splunking!

0 Karma

Gr0und_Z3r0
Contributor

Something like this....

| makeresults
| eval adminlocal = "labmachine000r\administrator labmachine000d\support labdomain\admingroup labdomain\helpdesk"
| eval adminlocal=replace(adminlocal, "\w+(\\\\)+","")
| eval mc = "L-02labmachine000r\administrator L-02labmachine000r\support L-02labmachine000r\admingroup L-02labmachine000r\helpdesk labdomain\admingroup labdomain\helpdesk L-99labmachine000r\admingroup L-0216labmachine000r\helpdesk"
| eval new_mc=replace(mc,"[\w\d\-]+(\\\)+","")

Gr0und_Z3r0_0-1637843842052.png

 

Please upvote if it helps.

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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