# How to clean a string from invisible characters?

**URL:** <https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [March 18, 2026, 11:17am UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549 "2026-03-18T11:17:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [March 18, 2026, 11:17am UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/1 "2026-03-18T11:17:34Z")

</div>

Hi!

I have a script that reads from an excel. In that excel there is a list of names and configuration to import as tags.

However, sometimes Excel writes nonprintable characters and those are not valid for tag names.  
Is there any way to clean a string to only have valid tag names characters? The idea is to clean it so I only get the intendeed name.

Here my problem. THe WJ invisible character...

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/f/1fb131fec2b37b381da9478756a506c076247991.png)

Thx in advance!

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [March 18, 2026, 12:12pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/2 "2026-03-18T12:12:10Z")

</div>

Spaces are allowed in tag names, even if some people severely dislike this.

However, in your example, and in a quick test I did (8.1.35), Ignition is ignoring the WJ anyway?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/0/602781239b7f179dc11b68ad89f3f508905f51a5.png)

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [March 18, 2026, 12:17pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/3 "2026-03-18T12:17:57Z")

</div>

My problem is creating the tags.

 ![{16AA0A98-D598-40D1-88A4-88783F2A146A}](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/5/1515babd489a6fb26a897b930935216913d9e829.png)

`[Error_Configuration("The name '⁠NonAvailableStatus' is not a valid tag name")] `

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 18, 2026, 12:22pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/4 "2026-03-18T12:22:20Z")

</div>

Try `translate`

```python
>>> import string
>>> s = "foo\r\nbar"
>>> s.translate(None, string.whitespace)
'foobar'

```

---

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [March 18, 2026, 12:32pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/5 "2026-03-18T12:32:59Z")

</div>

Or a small regexp works  
`import re`  
`''.join(re.findall('\w+' ,'`Non⁠Available’`)),`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 18, 2026, 12:51pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/6 "2026-03-18T12:51:17Z")

</div>

My Integration Toolkit has [mungeColumnName()](https://www.automation-pros.com/toolkit/doc/scripting.html#mungecolumnname) functions (expression and script) that will do this for you. Originally created to make dataset column names into jython-acceptable variable names for the `view()` expression function.

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [March 18, 2026, 1:39pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/7 "2026-03-18T13:39:14Z")

</div>

I think I'm going to do this:

```python
''.join(
	c for c in text
	if c in set("0123456789_ '-:()") or unicodedata.category(c)[0] == 'L'
)

```

_Note: I didn't check if is a bad implementation for high amount of data_

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [March 18, 2026, 1:40pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/8 "2026-03-18T13:40:29Z")

</div>

Does work but for me but removes the accents (I'm spanish).

Thing like this `Compresión` turn into this `Compresin`.

---

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [March 18, 2026, 2:04pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/9 "2026-03-18T14:04:54Z")

</div>

Then, instead of \w, use [0-9A-Za-zÀ-ÿ].  
It should cover your needs

```python
''.join(re.findall("[0-9A-Za-zÀ-ÿ]+" ,'Compresión'))

```

Edit : forget that, it does not work for a tag name.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 18, 2026, 3:53pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/10 "2026-03-18T15:53:05Z")

</div>

Apache StringUtils

```python
from org.apache.commons.lang3 import StringUtils

stringList = ['Compresión', 'Crème brûlée', 'über', 'garçon', 'Señor']

for s in stringList:
	print StringUtils.stripAccents(unicode(s))

```

output:

```plaintext
Compresion
Creme brulee
uber
garcon
Senor
>>> 

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 18, 2026, 7:13pm UTC](https://forum.inductiveautomation.com/t/how-to-clean-a-string-from-invisible-characters/114549/11 "2026-03-18T19:13:12Z")

</div>

Had some time to sit with this a bit more. If you're working with unicode, it's usually wise to import unicode\_literals

[StringUtils()](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html) seems like it can do everything you need

```python
from __future__ import unicode_literals
from org.apache.commons.lang3 import StringUtils

def normalize(stringIn, replaceDict={'':''}):
	return StringUtils.stripAccents(StringUtils.replaceEach(StringUtils.normalizeSpace(stringIn), replaceDict.keys(), replaceDict.values()))

# Dictionary of any odd values you want to filter for.
# e.g: WordJoin is '\u2060' and has to be used it is not considered whitespace. 
replaceDict = {'\u2060' : ''}

stringList = [' Compres\u2060ión', 'Crème\r\nbrûlée', 'über', 'garçon', 'Señor']

for s in stringList:
	repr(normalize(s, replaceDict))

```

output:

```plaintext
"u'Compresion'"
"u'Creme brulee'"
"u'uber'"
"u'garcon'"
"u'Senor'"
>>> 

```
