>Jakob Voss writes:
> > So 1-based should not be used because of additional non-standard
> > fancy stuff that nobody will use, but because of it's standard in
> > modern query languages.
>Strong argument.
It has my vote :)
>So how about this:
> substring := <start1> [ ':' <length> ]
>Where <start1> is a one-based character-count (0 is illegal) and the
>:<length> is optional. If <length> is negative, it counts backwards
>from the end of the string. So:
>
> 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 "" ?
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.
Rob
|