OK, the current behaviour seems daft to me. Can anyone explain why this is
as it is?

StringUtils.sliceFirst("abc", "") = "abc"
StringUtils.sliceFirst("abc", "d") = ""

StringUtils.sliceFirstRemainder("abc", "") = ""
StringUtils.sliceFirstRemainder("abc", "d") = "abc"

I would expect the exact opposite:
StringUtils.sliceFirst("abc", "") = ""
StringUtils.sliceFirst("abc", "d") = "abc"

StringUtils.sliceFirstRemainder("abc", "") = "abc"
StringUtils.sliceFirstRemainder("abc", "d") = ""


I would expect slice first to return the text before the first separator. An
empty string is found at position zero, so it should return "". Separator
"d" is not found, so everything before it is the whole string.

I'd like to change this, but why is it as it is???

Stephen

----- Original Message -----
From: "Phil Steitz" <[EMAIL PROTECTED]>
To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
Sent: Tuesday, July 22, 2003 3:30 PM
Subject: Re: [lang] StringUtils.sliceFirstRemainder behavior


> Stephen Colebourne wrote:
> > I think I would expect:
> >
> > StringUtils.slice("foo", "b") = "foo"
> > "get everything before the last 'b'"
> >
> > StringUtils.sliceRemainder("foo", "b") = ""
> > "get everything after the last 'b'"
> >
> > StringUtils.sliceFirst("foo", "b") = ""
> > "get everything before the first 'b'"
> >
> > StringUtils.sliceFirstRemainder("foo", "b") = "foo"
> > "get everything after the first 'b'"
> >
> > slice and sliceRemainder are opposite.
> > The results would be the same for a blank separator.
> >
> > But then I don't use Perl which is where I think these came from.
> > So wait to see if you get any more answers!
> >
> > Stephen
> >
>
> I just submitted a patch here
>
> http://issues.apache.org/bugzilla/show_bug.cgi?id=21797
>
> that documents current behavior with examples and test cases.
>
> Phil
>
> > ----- Original Message -----
> > From: "Phil Steitz" <[EMAIL PROTECTED]>
> > To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
> > Sent: Tuesday, July 22, 2003 5:50 AM
> > Subject: [lang] StringUtils.sliceFirstRemainder behavior
> >
> >
> >
> >>Currently,
> >>
> >>StringUtils.sliceRemainder("foo", "b") = ""
> >>= StringUtils.sliceFirst("foo", "b"),
> >>
> >>but StringUtils.sliceRemainder("foo", "b") = "foo".
> >>
> >>Is this the intended behavior?
> >>
> >>Phil
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>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]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to