- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Remove the query string from a Url field
gassershaun
Engager
12-06-2012
04:18 AM
Need to exclude the query parameters from a URL field.
For e.g. the field contains http://www.google.com/india?search=splunk. I need to substring this such that result field only contains http://www.google.com/india i.e. remove the part following "?" character. Tried using the eval and the replace functions but did not work...
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
zsteinkamp_splu

Splunk Employee
03-14-2018
11:04 AM
Ayn's answer fails if the URL does not include a question mark. Here is a regex that works for URLs with and without a question mark:
| rex field=your_url_field "^(?<your_new_url_field>[^?]+)
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ayn
Legend
12-06-2012
04:20 AM
... | rex field=your_url_field "^(?<your_new_url_field>.+?)\?"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ayn
Legend
12-06-2012
04:37 AM
Ah. Updated my answer with a corrected regex.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
gassershaun
Engager
12-06-2012
04:35 AM
Thanks it works.. however one small problem I get the result as http://www.google.com/india? and not as http://www.google.com/india I also need to get rid of the ending ?
