[texhax] The last character of a string
Pierre MacKay
pierre.mackay at comcast.net
Fri Jan 29 01:42:08 CET 2010
On 01/28/2010 03:25 PM, Michael Barr wrote:
> Is there a simple way to find the last character of a string? Assume
> the string is brace delimited. What I want to do is add a period
> unless the string already ends in a period, question mark, or
> exclamation mark, but I don't see any way short of going through the
> string knocking off one character at a time.
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org
>
I assume that this has to be done within TeX. Otherwise it is a
function of whatever editor you are using:
It is a problem I often find, and I use the emacs "narrow-to-region"
command. Find whatever triggers the opening brace,
save the position and then (if there are no intervening paired braces)
find the closing brace. Narrow to region, and then search just before
the closing brace. It is very fast indeed.
The need for this ability to narrow to a specific context is one of the
reasons for providing specific *begin* and *end* macros in many
contexts, rather than insisting that the context appear as a macro
parameter. The LaTeX adapters of Ibycus have insisted on the macro
parameter model, but in Plain Tex I stick with \GK{} and \RM{} which
allow a clean "narrow-to-region" operation on any passage of any size.
These macros make it possible to run efficiently through a long article
and check the correctness of the Greek without having to scroll through
all the non-Greek text.
Pierre MacKay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20100128/dcbe1cde/attachment.html>
More information about the texhax
mailing list