Is there a way to remove ASCII Characters with a decimal value of 127 or higher from a TEXT String?
I'd use the keepchars() function to keep only the necessary characters. To generate the string of characters to keep, you can use the workflow below.
keepchars.morph (4.9 KB)
Alternatively, use the new "Generate expression" feature of the Expression Editor. It suggested using a regular expression. I'm not a fan of regular expressions, but it does the job.
regexreplace([TEXT], "", "[\u007F-\uFFFF]")
I cannot use the keepchars function because that would remove the invalid character and if it in the middle of a name, i need to replace it with a blank. The regexreplace function should do the job is I change the replacement string with " " or so I thought. The coding did not work! I will try to attach the project I created, so you can see and suggest what I am doing wrong.
Check Text for Invalid Characters.morph (18.3 KB)
The attached project better solves the problem. Please comment. If you look at the details, the shared memory commands that return the prior data seems to remove LEADING Spaces. I do not understand this because when I test the action in a separate project, leading spaces are retained. Anyway, leading spaces are not important since they are going to be removed anyway with a Trim function.
I'm not sure I understand clearly what you're trying to achieve - replace or remove? Do you need to replace all invalid characters with a space no matter where they are located? Or should they be treated differently depending on whether they are in the middle of a text string or word, or not?
Please provide a few examples to illustrate your case.
Splitting into characters can work too. You don't need the "Combine Char to Text" module - you can replace it with the "Concatenate text" action (without using a separator).
"to replace all invalid characters with a space no matter where they are located" is what I am tyrying to do.
What if there are repeating spaces after the replacement - is that OK, or not? For instance, you had "AxyzB" and then replaced "x", "y", and "z" with spaces, what should be the result?
