Hi,
I am looking for a quick way in Java to change the string:
" this is it "
to "this is it"
I want to replace all multiple spaces with a single space. I also want all the spaces at the end and begining of the string to go away as well.
Use String trim() method to trim spaces at the begining and end of the string. For other spaces within words use:
mytext = mytext.trim() mytext = mytext.replaceAll("( )+", " ")
<code>
<blockcode>
<c>
<cpp>
<drupal5>
<drupal6>
<java>
<javascript>
<php>
<python>
<ruby>
<foo>
[foo]
Use String trim() method to trim spaces at the begining and end of the string. For other spaces within words use:
Post Comment