This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes using string replace Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "using string replace" Watch "using string replace" New topic
Author

using string replace

Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
I have a string which contains a indefinite/random spacing between words.
ex. "IE Mozilla Apache Netscape"
I want to convert into an even-spaced string - "IE Mozilla Apache Netscape"
Can someone suggest a way to achieve this?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Create a regular expression to match any number of whitespace characters. Use String.replaceAll() to replace each occurrence of this with one space character. Job done.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: using string replace
 
Similar Threads
Passing a Value from Popup Window back to the Parent Window
Why does the User-Agent=Mozilla/4.0 when I use MSIE 6.0?
javascript
how to know whether the browser is IE or netscape
How to make a JavaBrowser