Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
Beginning Java
Stripping Out Carriage Returns
Steve Dyke
Ranch Hand
Posts: 2232
2
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Why would the following code not take out the carriage returns and line feeds?
descptn = rs.getString("descrip").replaceAll("\r\n"," ").trim();
Paul Sturrock
Bartender
Posts: 10336
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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:
replaceAll("[\\r]*[\\n]*","")
[ May 08, 2008: Message edited by: Paul Sturrock ]
JavaRanch FAQ
HowToAskQuestionsOnJavaRanch
Jim Yingst
Wanderer
Posts: 18671
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Or perhaps
str.replaceAll("[\\r\\n]+", "");
"I'm not back." - Bill Harding,
Twister
Alas, poor Yorick, he knew this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Carriage Return?????????
Stripping Carriage Returns
Clear Windows Console....
Multiplication Table
How do I find a text file is Unix or Dos format via Java API?
More...