Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

remove spaces, regex

807603Dec 19 2007 — edited Dec 19 2007
Hi

I am trying to remove spaces from a string like this
Strins s = "object  This  .setSomething(rs          .getString("something")  )";
//regex i am using is
Pattern.compile("\\b\\s+\\b");
But using that regex, the String I get back is like this
objectThis .setSomething(rs .getString("something"))

So it seems like that it removes spaces from everywhere else except when there is a '.' (dot). What can i add to my regex to avoid this issue?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 16 2008
Added on Dec 19 2007
2 comments
158 views