We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › avoid linebreak on /n in a String
Page Index Toggle Pages: 1
avoid linebreak on /n in a String (Read 380 times)
avoid linebreak on /n in a String
Aug 25th, 2009, 9:49am
 
I get passed different strings and want to avoid a linebreak if one of them contains a /n cause it messes up my programm. Is there any easy way to avoid a linebreak ? or should i search the string and replace it somehow?

are there more of these kind i should take care of ?
Re: avoid linebreak on /n in a String
Reply #1 - Aug 25th, 2009, 11:25am
 
Code:
String str = "Test\r\ntest";
str = str.replaceAll("[\r\n]+", "");
println(str);

To maximise portability, you should search for both \r and \n, since different OSes have different combinations of one, the other or both. If you want a space between the lines, put a space between the last two quotation marks.
Re: avoid linebreak on /n in a String
Reply #2 - Aug 25th, 2009, 11:48am
 
great, thx for your help
Page Index Toggle Pages: 1