commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tatu Vanhanen" <tatu.vanha...@graftor.fi>
Subject RE: [lang] StringUtils.strip
Date Wed, 05 May 2004 05:15:59 GMT

CharSetUtils.delete(number, "-") will also do it for you.

Don't be confused, though, by the method's javadoc. It seems to be
copy-pasted directly from the CharSetUtils.keep- method, which does the the
contrary to delete (keeps the specified characters removing everything
else).

- Tatu V.

> -----Original Message-----
> From: Mike Zatko [mailto:mzatko@boscovs.com]
> Sent: 5. toukokuuta 2004 0:10
> To: Jakarta Commons Users List
> Subject: Re: [lang] StringUtils.strip
>
>
> Yep. I misread it as start to end of the String. Thanks.
>
> Charles Hudak wrote:
>
> >The javadoc explicitly says:
> >
> >"Strips any of a set of characters from the start and end of a String.
> >This is similar to String.trim() but allows the characters to be
> >stripped to be controlled"
> >
> >Your characters are neither at the start or end of the string, hence
> >nothing happens.
> >
> >You probably want to do this:
> >
> >StringUtils.replace(number, "-", "");
> >
> >
> >
> >-----Original Message-----
> >From: Mike Zatko [mailto:mzatko@boscovs.com <mailto:mzatko@boscovs.com>
> >]
> >Sent: Tuesday, May 04, 2004 1:50 PM
> >To: Jakarta Commons Users List
> >Subject: [lang] StringUtils.strip
> >
> >
> >I have a problem with the strip method:
> >
> >        String number = "610-926-6598";
> >        String newNumber = StringUtils.strip(number, "-");
> >        System.out.println("newNumber: '" + newNumber + "'");
> >
> >Output:
> >newNumber: '610-926-6598'
> >
> >According to the JavaDoc, this should strip out the hyphens but it does
> >not. A matter of fact I cannot get it to strip anything.
> >
> >http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/Strin
> >gUtils.html#strip(java.lang.String,%20java.lang.String
> ><http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/Stri
> >ngUtils.html#strip(java.lang.String,%20java.lang.String> )
> >
> >--
> >
> >Michael H. Zatko
> >WebSphere Developer
> >Boscov's Information Services
> >Work: 610-929-7317
> >Home: 610-562-2407
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
> >
>
>
> --
>
> Michael H. Zatko
> WebSphere Developer
> Boscov's Information Services
> Work: 610-929-7317
> Home: 610-562-2407
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message