# How can I get a soft return?

I want to have two different type of newline so I can print a string which looks like it has multiple newlines but gives me a way to differentiate between them. I want to have string with newlines in them and look them up using RegularExpresssion["...\n...\r..."]->.... Basically there will be a huge string with mix of hard and short returns then I will have a bunch of StringReplace[...] where \n will be captured and replace by something and \r by something else.

• Is there a way to have hard and soft returns in a Mathematica string?
• If I should write a string like "sdfsdf\nadsad\rasdasd", is there a function, say StringPrint["sdfsdf\nadsad\rasdasd"], which will convert the "\n" and "\r" to their print form? Note: For this I want to do inline evaluation by first selecting and pressing Ctrl+Shift+Enter not Shift+Enter evaluation.

Enter is the keybinding for \[Newline] which is \n but since Shift+Enter is reserved for evaluation while it is a standard key for soft return \r. If \[Newline] equivalent for \r can be found that would still make the life easier as well.

• I don't really understand. Simply Printing a string (or returning it from an evaluation) with line ending characters will show those characters as line breaks. – Sjoerd Smit Mar 24 '19 at 10:29
• I think I found it \:000a is the hex way to enter \n and \:000d is the hex way to enter \r and I think hex way might be the only way to input in print form \r. \n already has a key binding Enter and various aliases like \[Newline], \[RawReturn], \[ParagraphSeparator] etc , does \r also has some hidden keybinding or aliases? – user13892 Mar 24 '19 at 12:08
• Oh, wait. I think I get it. Can't you just escape the backslash? I.e., StringReplace[str, {"\r" -> "\\r", "\n"-> "\\n"}] – Sjoerd Smit Mar 24 '19 at 18:36