Feb 26, 2004 #1 JontyMC Programmer Joined Nov 26, 2001 Messages 1,276 Location GB I have a string with new line characters in such as: str = "A line\nAnother line\nYet another line"; 1. How do remove all the \n characters? 2. How do I replace all the \n characters with another character? Thanks, Jon
I have a string with new line characters in such as: str = "A line\nAnother line\nYet another line"; 1. How do remove all the \n characters? 2. How do I replace all the \n characters with another character? Thanks, Jon
Feb 26, 2004 #2 sedj Programmer Joined Aug 6, 2002 Messages 5,610 Its amazing what you find in the API documentation !!! http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html Code: String a = "A line\nAnother line\nYet another line"; a = a.replaceAll("\n"," "); Upvote 0 Downvote
Its amazing what you find in the API documentation !!! http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html Code: String a = "A line\nAnother line\nYet another line"; a = a.replaceAll("\n"," ");