how to delete special characters from text ?

775 views
Skip to first unread message

Kurien Eapen

unread,
Dec 22, 2015, 8:05:46 AM12/22/15
to MIT App Inventor Forum
I wanted to eliminate the special characters from a list please help.  

oaltair

unread,
Dec 22, 2015, 11:18:01 AM12/22/15
to MIT App Inventor Forum
Could you be more explicit?  
Thanks!

Kurien Eapen

unread,
Dec 22, 2015, 11:26:29 AM12/22/15
to MIT App Inventor Forum
I actually want to eliminate the special characters like  -,*,&,(,)<,?....etc from a piece of text . The purpose is to compare two text but i have to eliminate special characters in one of them .

Abraham Getzler

unread,
Dec 22, 2015, 11:39:30 AM12/22/15
to MIT App Inventor Forum
I have attached a screen shot of a special purpose routine to
change all occurrences of hex FEFF (a Byte Order Marker) to blank
in a string.  

This would help you only if you know in advance what you want to strip.
If you want to remove all unreadable characters from a string,
try this code ...
VALID_Chars = " 0123456789abcdefg...xyzABCD...XYZ"
FOR I = 1 to length(inputstring)
   IF NOT(CONTAINS(VALID_Chars,segment(inputstring,I,1)) THEN
        REPLACE(inputstring,I," ")
end FOR

If you want to do it to a list, do it to each element of the list
one by one.


strip_BOM.png

Scott Ferguson

unread,
Dec 22, 2015, 11:56:23 AM12/22/15
to MIT App Inventor Forum
Here is one way to do it both with and without a space character:

---

sf


Kurien Eapen

unread,
Dec 22, 2015, 12:06:50 PM12/22/15
to MIT App Inventor Forum
Thanks Abraham Getzler for the reply, i will surely try. 

Kurien Eapen

unread,
Dec 22, 2015, 12:10:56 PM12/22/15
to MIT App Inventor Forum
Thanks Scott Ferguson , your code seems to be much more simpler , i'm just a beginner .I've only learnt App Inventor for 6 weeks from a course in Edx by TrinityX so i'm just getting a hang of it .
Reply all
Reply to author
Forward
0 new messages