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.
You may not like it, but REPLACE
is 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:
DEFINE VARIABLE str AS CHARACTER NO-UNDO.
DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.
DO iLoop = 1 TO 31:
str = REPLACE(str, CHR(iLoop), " ").
END.
Since there are multiple control characters that have to be removed, it seems that any solution will involve multiple iterations.
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: