I want to remove all control character from the given string. i don't want to use Replace method because it take multiple iteration. Help me.
Thanks in advance.
I want to remove all control character from the given string. i don't want to use Replace method because it take multiple iteration. Help me.
Thanks in advance.
On
Depending on what you define as a control character and what character set you are using this might do the trick. Or at least point you in a helpful direction:
define variable i as integer no-undo.
define variable n as integer no-undo.
define variable c as character no-undo.
define variable s as character no-undo.
define variable x as character no-undo.
s = "something with control characters in it".
x = "".
n = length( s ).
do i = 1 to n:
c = substring( s, i, 1 ).
if asc( c ) >= 32 and asc( c ) < 127 then
x = x + c.
end.
You may not like it, but
REPLACEis the simplest way to do it. I've used this code to strip non-printable characters from a string. This will replace the control characters with a space:Since there are multiple control characters that have to be removed, it seems that any solution will involve multiple iterations.