- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9jamie
Explorer
04-26-2022
12:03 PM
I'm new to regex and having trouble extracting some text. My raw data is in the following format:
ID=[12839829389-8b7e89opf][2839128391DJ33838PR]
I need to extract the text between the first two brackets,12839829389-8b7e89opf, into a new field.
So far what I have does not work: | rex field=_raw "ID=[(?<id>.*)]"
If anyone could help it would be greatly appreciated.
1 Solution
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ITWhisperer

SplunkTrust
04-26-2022
12:09 PM
Square brackets are special characters in regex so need to be escaped with backslashes
| rex field=_raw "ID=\[(?<id>.*)\]"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ITWhisperer

SplunkTrust
04-26-2022
12:09 PM
Square brackets are special characters in regex so need to be escaped with backslashes
| rex field=_raw "ID=\[(?<id>.*)\]"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9jamie
Explorer
04-26-2022
12:42 PM
this returns everything after ID up until the final closing bracket. so i added the brackets containing the second part of the id as well. final solution:
rex field=_raw "ID=\[(?<id>.*\]\[.*\]"
thanks for the help
