- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to remove all non-ascii character from search results?

ccloutralex
Observer
04-12-2022
07:04 AM
I have a fairly large(3,400 records) search result that randomly contains non-ascii characters in any one of the 20 fields. This normally is not an issue but the sendemail.py script that is used by splunks email alerting system is erroring out because of it. Is there a way to remove non-ascii characters from all search results? See below for search example:
| inputlookup StatusReport.csv | fields Name ID BusinessGroup Class Email Issues Comments Dynamic Status Owner HoB | sort ID
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
VatsalJagani

SplunkTrust
04-18-2022
08:57 AM
@ccloutralex - Can you please try below search?
| inputlookup StatusReport.csv | fields Name ID BusinessGroup Class Email Issues Comments Dynamic Status Owner HoB | sort ID
| foreach * [| rex field="<<FIELD>>" mode=sed "s/[^\x00-\x7F]/ /g"]
This will replace any non-ascii character with space.
I hope this helps. If it does consider upvoting!!
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Gr0und_Z3r0
Contributor
04-18-2022
05:56 AM
Hi @ccloutralex
If you know the fields that have non-ascii characters, try to replace them using sed command.
| rex mode=sed field=<fieldname> "s/<whatyouwannachange>/<whatitshouldbeafterwards>/g"
