- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
smcdonald20
Path Finder
06-01-2017
03:36 AM
I have a field, where all values are pre-fixed with "OPTIONS-IT\".
I would like to remove this, but not sure on the best way to do it.
example
User
OPTIONS-IT\smcdonald
OPTIONS-IT\jbloggs
I would like to change to
User
smcdonald
jbloggs
I have tried eval User= replace (User, "OPTIONS-IT\", "") but this doesn't work.
The regular expressions I have used have not worked either.
Any help appreciated.
1 Solution
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dineshraj9
Builder
06-01-2017
03:44 AM
These methods support regular expression and "\" will be treated as escape character.
Do it this way -
<your search> | rex field=User "OPTIONS.IT.(?<User>\S+)"
OR
<your search> | eval User=replace (User, "OPTIONS\-IT.", "")
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

woodcock
Esteemed Legend
06-01-2017
06:24 AM
Like this (needs more escape characters):
... | rex field=User mode=sed "s/OPTIONS-IT\\\//g"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

ljalvrdz
New Member
08-30-2018
04:06 PM
This one works great! Thanks!
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

gcusello

SplunkTrust
06-01-2017
04:21 AM
Hi smcdonald20,
Try the following command
your_search | rex field=your_field "OPTIONS-IT\\(?<username>[^ ]*)"
Bye.
Giuseppe
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dineshraj9
Builder
06-01-2017
03:44 AM
These methods support regular expression and "\" will be treated as escape character.
Do it this way -
<your search> | rex field=User "OPTIONS.IT.(?<User>\S+)"
OR
<your search> | eval User=replace (User, "OPTIONS\-IT.", "")
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
daymauler
Explorer
09-02-2021
05:29 PM
