Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25339

Re: how to trim() a String only at the right side?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: how to trim() a String only at the right side?
Date Wed, 25 Sep 2013 13:41:18 -0700
Organization A noiseless patient Spider
Lines 14
Message-ID <l1vhpg$ehn$1@dont-email.me> (permalink)
References <slrnl45qr1.mol.avl@gamma.logic.tuwien.ac.at> <l1vh7v$bjh$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 25 Sep 2013 20:41:21 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="9185b88a2b5381a82810209530bb8295"; logging-data="14903"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kwKM/o6kiGqvFC+//abBVp+izaDldaw0="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
In-Reply-To <l1vh7v$bjh$1@dont-email.me>
Cancel-Lock sha1:rfczA5TbU3Z777oUv/j0RssHbg0=
Xref csiph.com comp.lang.java.programmer:25339

Show key headers only | View raw


On 9/25/2013 1:31 PM, markspace wrote:

>    public CharSequence rTrim( CharSequence cs ) {
>      if( cs == null ) return null;
>      if( cs.length() == 0 || cs.charAt( cs.length()-1 ) != ' ' )
>        return cs;
>      int i = cs.length()-1;
>      while( i >= 0 && cs.charAt( i ) == ' ' ) i--;
>      return cs.substring( 0, i );

I realized just after I posted that the last line should probably be

      return cs.substring( 0, i+1 );

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

how to trim() a String only at the right side? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-09-25 13:55 +0000
  Re: how to trim() a String only at the right side? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-09-25 10:25 -0400
  Re: how to trim() a String only at the right side? "John B. Matthews" <nospam@nospam.invalid> - 2013-09-25 12:55 -0400
  Re: how to trim() a String only at the right side? Jim Janney <jjanney@shell.xmission.com> - 2013-09-25 13:05 -0600
  Re: how to trim() a String only at the right side? Silvio <silvio@internet.com> - 2013-09-25 21:46 +0200
  Re: how to trim() a String only at the right side? markspace <markspace@nospam.nospam> - 2013-09-25 13:31 -0700
    Re: how to trim() a String only at the right side? markspace <markspace@nospam.nospam> - 2013-09-25 13:41 -0700
      Re: how to trim() a String only at the right side? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-09-26 17:11 +0000
    Re: how to trim() a String only at the right side? Silvio <silvio@internet.com> - 2013-09-26 12:14 +0200
    Re: how to trim() a String only at the right side? Jim Janney <jjanney@shell.xmission.com> - 2013-09-26 09:44 -0600
      Re: how to trim() a String only at the right side? Arne Vajhøj <arne@vajhoej.dk> - 2013-09-26 13:01 -0400
  Re: how to trim() a String only at the right side? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-26 12:21 +0100
    Re: how to trim() a String only at the right side? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-26 17:40 +0100
  Re: how to trim() a String only at the right side? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-09-26 16:56 +0000

csiph-web