I have a character stream I have recieved from a device that contains non printable characters with in it. I want to remove these characters to make parsing easier.
My thoughts were to turn the string into a character array and using a for loop remove all char outside the range of a-z, A-Z, 0-9 [SPACE] [/n] then convert the character array back to a string. This seems resource hungery but I see no other alternative.
What about symbols?
I don't consider it resource hungry. I wouldn't turn it into an array of characters. I would just work on the string.
But there is probably a way to create a Regex that could do what you want and do a search and replace with it.
Actually, you original idea was good, it just needs a bit of tweaking. Converting a string to or from a U8 array in LabVIEW is an in-place operation and will cost you essentially nothing, since the two arrays are actually the same. Once you have the U8 array, you can use a bucket brigade algorithm to traverse your array. You can find details of the bucket brigade algorithm here (look at the fourth example). It is a very useful trick for using a single pass to remove arbitrary data from an array efficiently. In your case, use the array element to switch a case structure. This should be faster than a regex search and replace or using the search and replace VI multiple times.
But, you'd better make that last "\n", not "/n". For all the escaped but printable characters (space, tab, NL, etc.) you use a backslash, not a forward slash and make sure you are writing your regex string in "\ code" display or it still won't interpret them correctly.