Robert Sanderson writes:
> > 1:10 -- First ten characters
> > 0:10 -- *error*
> > 1 -- Whole string (from first to end)
> > 2 -- All of string except the first character
> > 1:-4 -- All of string except last four characters
> > 2:-1 -- All of string except first and last characters
>
> Like it.
>
> Two questions:
>
> 1. Is 1:0 an error, or "" ?
I don't see any reason for it to be an error. It's an odd thing to
ask for, yes, but as always I take the position that we can't know
what use people will put our stuff to, so if as in this case there is
a single meaningful interpretation of an expression, we should let
that interpretation stand. So <anything>:0 is a zero-length string.
> 2. Is it sufficiently useful to also allow negative numbers in the
> start position? eg: -10:3 -- 3 characters starting at the 10th
> from last.
I'd have no objection to that (though again I don't see any use for it
right now).
_/|_ ___________________________________________________________________
/o ) \/ Mike Taylor <[log in to unmask]> http://www.miketaylor.org.uk
)_v__/\ "I have no idea what a `strong' or a `weak' verb is, and I truly
hope I never find out what a `turbo verb' is, but I usually have
a pretty good idea what the *right* verb is" -- Jane MacDonald.
|