[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Question about .substring
From: |
Ralph Corderoy |
Subject: |
Re: [Groff] Question about .substring |
Date: |
Thu, 20 Nov 2014 13:10:36 +0000 |
Hi Ingo,
> > for example, and without introducing lengthy calculations
>
> Lengthy? If you have the offset and length (> 0), all it takes is one
> addition and decrementing by one.
I think his point is given string s of `abcdefghij', one wants the
substring starting at index 2, `c', of length 0, 1, or 2. `2 2' gives
`c', `2 3' `cd'. `2 1' is swapped to `1 2' giving `bc'. There's no
second parameter that gives an empty string, unlike the [startindex,
endindex) interval where endindex is exclusive, e.g. Python.
$ python -c 'print "abcdefghij"[2:2]' | od -c
0000000 \n
0000001
$
So that means testing the length number register to see if it's zero and
defining the string to be empty if it is, or doing the maths for
.substring otherwise.
Obviously, ;-)
the new expression syntax would have a substring function that returns
rather than modifies and uses the normal [) interval.
Cheers, Ralph.
- [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/19
- Re: [Groff] Question about .substring, Tadziu Hoffmann, 2014/11/19
- Re: [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/19
- Re: [Groff] Question about .substring, Ingo Schwarze, 2014/11/19
- Re: [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/19
- Re: [Groff] Question about .substring, Ingo Schwarze, 2014/11/19
- Re: [Groff] Question about .substring, Ralph Corderoy, 2014/11/19
- Re: [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/20
- Re: [Groff] Question about .substring, Ingo Schwarze, 2014/11/20
- Re: [Groff] Question about .substring,
Ralph Corderoy <=
- Re: [Groff] Question about .substring, Tadziu Hoffmann, 2014/11/20
- Re: [Groff] Question about .substring, Ralph Corderoy, 2014/11/20
- Re: [Groff] Question about .substring, Tadziu Hoffmann, 2014/11/20
- Re: [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/28
- Re: [Groff] Question about .substring, Ralph Corderoy, 2014/11/29
- Re: [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/22
- Re: [Groff] Question about .substring, Carsten Kunze, 2014/11/20
- [Groff] .fl (was: Question about .substring), Carsten Kunze, 2014/11/20
- Re: [Groff] Question about .substring, Ralph Corderoy, 2014/11/19
- Re: [Groff] Question about .substring, Ulrich Lauther, 2014/11/19