4
$\begingroup$

I have tried as many versions of the following function, but none work.

StringReplace["\[Backslash]" -> ""] /@ {"105\n7.497910", 
 "110\n8.761210", "110\n9.815710"}
$\endgroup$

1 Answer 1

3
$\begingroup$
list = {"105\n7.497910", "110\n8.761210", "110\n9.815710"};

StringReplace[#, "\n" -> "n"] &[list] // FullForm

enter image description here

$\endgroup$
3
  • $\begingroup$ I tried that (at least I think I did) and it didn't work. Thanks for restoring my faith in what I think I know. $\endgroup$ Commented Aug 19, 2017 at 0:08
  • $\begingroup$ Having an "n" on the rhs makes it work. I'm glad to know how to do it. Why can't you use an escape backslash to replace the backslash with ""? $\endgroup$ Commented Aug 19, 2017 at 0:15
  • 1
    $\begingroup$ Because "\n" (newline chatacter) is inseparable. You don't need the "n": StringReplace[#, "\n" -> ""] &[list] also works $\endgroup$
    – eldo
    Commented Aug 19, 2017 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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