commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [lang] StringUtils.substringAfter()
Date Tue, 14 Oct 2003 22:01:42 GMT
In some ways this is a hangover from the original StringUtils of everything
together.

In an ideal world, all the StringUtils methods that work on character sets
(whether by char[] or String of chars) should be in a separate utility
class. But that is pretty impractical now, especially as 2.0 was the release
where all these 'where to put this method' issues got resolved.

Maybe  removeStartsWith("www.")  and  removeEndsWith(".com") ?? I think they
are worthy additions.

Stephen

----- Original Message -----
From: "__matthewHawthorne" <matth@phreaker.net>
> I don't think that your case is unusual.  Actually, I would expect
> stripStart to do what you want, and (a nonexistent) stripStart(String,
> char[]) to do what the current stripStart(String, String) does.
>
> However, this doesn't solve your problem.  I think your suggestion would
> be useful, but I'm not sure about a name either.
>
>
>
>
> Gary Gregory wrote:
> > No takers on discussing this one?
> >
> > Gary
> >
> >
> >>-----Original Message-----
> >>From: Gary Gregory [mailto:ggregory@seagullsw.com]
> >>Sent: Wednesday, October 08, 2003 11:43
> >>To: 'Jakarta Commons Developers List'
> >>Subject: [lang] StringUtils.substringAfter()
> >>
> >>Hello,
> >>
> >>I find the current behavior of StringUtils.substringAfter() not quite
> >>right
> >>for my needs. For example, I want to strip the leading 'www.' in a host
> >>string. If the search string is not there, the empty string is returned,
> >>which force me to write:
> >>
> >>String host = ...
> >>String strippedHost = StringUtils.substringAfter(host, "www.");
> >>if (StringUtils.isEmpty(strippedHost)) {
> >>   strippedHost = host;
> >>}
> >>//continue with stripped host.
> >>
> >>Instead of:
> >>
> >>String host = ...
> >>String host = StringUtils.substringAfter(host, "www.");
> >>//continue with stripped host.
> >>
> >>If the API returned the its argument instead of "".
> >>
> >>You'd think stripStart would do this but stripStart works on a character
> >>set, not a string prefix.
> >>
> >>So:
> >>
> >>(1) I do not thing that changing the current API is nice.
> >>
> >>(2) Does this case warrant a new API? Or is this case really unusual?
> >>New API: stripStartString(String, String)
> >>Perhaps rename (deprecate etc) startStart to startStartCharSet?
> >>
> >>Thanks,
> >>Gary
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


Mime
View raw message