This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stripping Out Carriage Returns

 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would the following code not take out the carriage returns and line feeds?

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you not asking it to replace only where there is a carriage return followed by a line break (plus I think you will need to escape the regex escape character)?

This does it I think:

[ May 08, 2008: Message edited by: Paul Sturrock ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or perhaps

str.replaceAll("[\\r\\n]+", "");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic