I'm glad I am not alone! ;-) Your names are good so I'm a go for them.

Note that:

StringUtils.replaceOnce(str, "www.", "");

Is not the same as:

removeStart(str, "www.")

since "www." could be removed from /anywhere/ in the string as opposed to
only from the /beginning/.

Gary

> -----Original Message-----
> From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
> Sent: Saturday, October 18, 2003 18:04
> To: Jakarta Commons Developers List
> Subject: Re: [lang] StringUtils.substringAfter()
> 
> Hmmm, I needed this one a couple of days ago, so it has value. But the
> name
> is problematical.
> 
> strip() is used for removing characters, so we should keep clear of that
> 
> removeStartsWith(str, "www.");
> removeStartingWith(str, "www.");
> removeStart(str, "www.");
> rightAfter(str, "www.");
> end(str, "www.");
> endAfter(str, "www.");
> endstringAfter(str, "www.");
> deleteStart(str, "www.");
> 
> Of all of these, I think the removeStart or deleteStart convey the message
> clearest, as they kindof imply that the rest of the string is untouched if
> the start is not found.
> 
> deleteStart() fits with the deleteWhitespace() method we already have, but
> removeStart() is a nicer name (as is removeWhitespace()). So I think we
> need
> a group of remove methods:
> 
> removeWhitespace()
> remove()
> removeStart()
> removeEnd()
> removeChars()
> 
> 
> Of course I finally realised that this can be achieved with what we
> currently have.....
>   StringUtils.replaceOnce(str, "www.", "");
> But I think a removeStart(str, "www.") is more obvious.
> 
> Stephen
> 
> ----- Original Message -----
> From: "Gary Gregory" <[EMAIL PROTECTED]>
> > I like removeStartsWith()/removeEndsWith() because it recalls
> > String.startsWith()/endsWith(), but reads a little weird due to the two
> > verbs. What about:
> >
> > StringUtils.removeStartingWith()
> > StringUtils.removeEndingWith()
> >
> > Or, since we already have stripStart() and even though I like 'remove'
> over
> > 'strip':
> >
> > StringUtils.stripStartingWith()
> > StringUtils.stripEndingWith()
> >
> > ?
> >
> > Gary
> >
> > > -----Original Message-----
> > > From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
> > > Sent: Tuesday, October 14, 2003 15:02
> > > To: Jakarta Commons Developers List
> > > Subject: Re: [lang] StringUtils.substringAfter()
> > >
> > > 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" <[EMAIL PROTECTED]>
> > > > 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:[EMAIL PROTECTED]
> > > > >>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: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to