1
$\begingroup$

I have imported string data, which appears to have line breaks or return codes in it invisible in a notebook input cell.

Copying a string and pasting into Apple Pages with control codes showing gets me this:

enter image description here

I've looked at StringDelete, but can't see a way to make it work for control characters.

How can I remove them?

$\endgroup$
5
$\begingroup$

To remove line breaks from a string with StringDelete, you can simply do this:

string = 
  "I have imported string data, which appears to have line breaks or return codes in it invisible in a notebook input cell.

  Copying a string and pasting into Apple Pages with control codes showing gets me this:";

StringDelete[string, "\n" | "\r"]

(*
==> "I have imported string data, which appears to have line breaks or return codes in it invisible in a notebook input cell.Copying a string and pasting into Apple Pages with control codes showing gets me this:"
*)
$\endgroup$
  • $\begingroup$ I knew if had to have a simple solution. Thx. $\endgroup$ – Jagra Jun 27 '15 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.