aspose file tools*
The moose likes Beginning Java and the fly likes Stripping Out Carriage Returns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Stripping Out Carriage Returns" Watch "Stripping Out Carriage Returns" New topic
Author

Stripping Out Carriage Returns

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
Why would the following code not take out the carriage returns and line feeds?

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Or perhaps

str.replaceAll("[\\r\\n]+", "");


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stripping Out Carriage Returns