stripping newlines

Hi

How do i strip out the extra escaped \\\ and \\n in the string?

Curran \\\"Gene\\\"  singer, film director and producer, and choreographer. Kelssly was known for his energetic and athletic dancing style, his good looks and the likeable characters that he played on screen.\\nAlthough he is known today for his performances in An American in Paris and Singin' in the Rain,  His many innovations transformed the Hollywood musical film, and he is credited with almost single-handedly making the ballet form commercially acceptable to film audiences.\\n
VlearnsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Try

final String PAT = "\\\\{2,3}n?";
s = s.replaceAll(PAT, "");

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zzynxSoftware engineerCommented:
        String s  = "Curran \\\"Gene\\\" singer, film director and producer, and choreographer. Kelssly was known for his energetic and athletic dancing style, his good looks and the likeable characters that he played on screen.\\nAlthough he is known today for his performances in An American in Paris and Singin' in the Rain,  His many innovations transformed the Hollywood musical film, and he is credited with almost single-handedly making the ballet form commercially acceptable to film audiences.\\n";
        final String pattern1 = "\\\\n";
        s = s.replaceAll(pattern1, ""); // Replace <two backslashes followed by the character n> by an empty string (iow, remove that)
        final String pattern2 = "\\\\\\\"";
        s = s.replaceAll(pattern2, "\""); // Replace <three backslashes followed by a "> with just a <">
        System.out.print(s);

Open in new window


Result:
Curran "Gene" singer, film director and producer, and choreographer. Kelssly was known for his energetic and athletic dancing style, his good looks and the likeable characters that he played on screen.Although he is known today for his performances in An American in Paris and Singin' in the Rain,  His many innovations transformed the Hollywood musical film, and he is credited with almost single-handedly making the ballet form commercially acceptable to film audiences.
0
CEHJCommented:
:)
0
zzynxSoftware engineerCommented:
Thanx 4 axxepting.
Better late than never ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.