commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From __matthewHawthorne <>
Subject Re: [lang] StringUtils.substringAfter()
Date Fri, 10 Oct 2003 23:39:51 GMT
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 []
>>Sent: Wednesday, October 08, 2003 11:43
>>To: 'Jakarta Commons Developers List'
>>Subject: [lang] StringUtils.substringAfter()
>>I find the current behavior of StringUtils.substringAfter() not quite
>>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.
>>(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?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message