The new NodeBox forum is live! Everything from support.nodebox.net moved here: sign in with the same email to pick up your old posts. Something not working? Write to forum-support@nodebox.net.
Is there any way within NodeBox to strip carriage returns and line feeds out of a sting?
I tried feeding \r and \n into a replace node but that didn't work. I suppose I could make a custom node to do this, but it would be nice not to have to do this. I wish the trim node could also trim carriage returns, line feeds, and tabs.
John
JO
JOjohn
Since I hate having to make custom nodes that I then have to keep track of, I decided to see if I could find some way of doing this entirely within NodeBox. It wasn't easy but I finally came up a way (attached). It's complicated, but it works.
The As_NumberList node converts the string into ASCII values. I then test for linefeeds (ASCII 10), convert the string to characters and use a Cull and a First to isolate a single LineFeed character (10). Once I have that I can feed it into a Replace node. If there are no linefeeds I just pass through the original string using a switch.
This exercise would not have been necessary if there was some way of entering a line feed directly into the OLD field of a Replace node. (Is there?). One alternative would be to provide a CHAR node that converts an ASCII code back into a character. It's weird that you can convert a char into ASCII but not the other way around.
This subnetwork could be easily modified to deal with other invisible characters.