groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [groff] Changing A Defined String


From: Peter Schaffter
Subject: Re: [groff] Changing A Defined String
Date: Sun, 28 Jan 2018 17:55:08 -0500
User-agent: Mutt/1.5.24 (2015-08-30)

On Mon, Jan 29, 2018, Robert Thorsby wrote:
> Tadziu asked me to post my solution, so here goes.  Essentially, I searched
> sequentially for ", "; the successful result gave me their position in the
> string.  The four levels of search were brought about by the fact that in
> the English names for the days of the week three have 6 characters, one has
> 7, two have 8, and one has 9.

Gotta throw my two cents' worth in.  Surely the simplest way to
write this (for contemporary groff) is

.ds DATE*FULL  Sunday, January 28 2018
.ds FIND*COMMA \*[DATE*FULL]
.nr foo -1 1
.while 1 \{\
. substring FIND*COMMA \n+[foo] \n[foo]
. if '\*[FIND*COMMA]',' .break
. ds FIND*COMMA \*[DATE*FULL]
.\}
.ds DATE*SHORT \*[DATE*FULL]
.substring DATE*SHORT \n[foo]+2

-- 
Peter Schaffter
http://www.schaffter.ca



reply via email to

[Prev in Thread] Current Thread [Next in Thread]