grep

Best way to strip line breaks

jeremydouglass's picture

I'm writing a series of patches that take text input from either the keyboard or through a file loader, and I've been trying Kineme Freeboard and Kineme String With File.

My problem: I'm trying to strip line feeds / enters / carriage returns from text strings, whether loaded from a file or aggregated through keystrokes. However, they seem to be encoded differently by Freeboard and String With File. I have come up with a temporary solution, but I'd love suggestions for something more robust.

In the attached patch, you can either load a file (Multiplex 0) or type (Mutiplex 1). Either way, the string gets passed through two "String Replace":

  1. Once using the invisible "ctr+opt+enter" character that can be entered into QC via keyboard (and matches against enter keys passed by Kineme FreeBoard) -- not sure, maybe this is '\r'?
  2. Once using a '\n' passed from JavaScript (that matches against line breaks passed by Kineme String With File)

This works (the lines are successfully stripped), however I suspect that there is some easier / more graceful / more efficient way of doing this. Possibly with a single JavaScript command that uses either str.replace or RegExp?

Any advice appreciated.

http://kineme.net/Discussion/DevelopingCompositions/CarriageReturns http://cybero.co.uk/QuartzComposerJavaScriptGuide-Eng/objects/String/rep...