[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: |
Wed, 19 Nov 2014 17:24:22 +0000 |
Hi Steffen,
> > > Replace the string named xx with the substring defined by
> > > the indices n1 and n2.
> >
> > Maybe:
> >
> > Replace the string named xx with its substring beginning with
> > the zero-based index n1 and ending with index n2, inclusively.
>
> Inclusive index n2 of the _resulting substring_, please.
But n2 is relative to the start of the original value of xx.
$ nroff
.ds s abcdefghij
.substring s 3 5
.tm \*s
def
^D
$
The full documentation of .substring wasn't originally given.
-- Request: .substring str n1 [n2]
Replace the string named STR with the substring defined by the
indices N1 and N2. The first character in the string has index 0.
If N2 is omitted, it is taken to be equal to the string's length.
If the index value N1 or N2 is negative, it is counted from the
end of the string, going backwards: The last character has
index -1, the character before the last character has index -2,
etc.
.ds xxx abcdefgh
.substring xxx 1 -4
\*[xxx]
=> bcde
I think the only thing it doesn't cover is what happens if characters
off the end of the original string are requested, e.g. are spaces
delivered? The answer is no, the requested characters are truncated to
the end of the source.
Note, `3 6' and `6 3' give the same result; N1 and N2 are inclusive
indices in either order.
Cheers, Ralph.
- Re: [Groff] Question about .substring, (continued)
- 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, 2014/11/20
- 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/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 <=
- Re: [Groff] Question about .substring, Ulrich Lauther, 2014/11/19
- Re: [Groff] Question about .substring, Ralph Corderoy, 2014/11/20