<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 01/28/2010 03:25 PM, Michael Barr wrote:
<blockquote
 cite="mid:Pine.LNX.4.64.1001281821510.598@msr03.math.mcgill.ca"
 type="cite">Is there a simple way to find the last character of a
string?&nbsp; Assume the string is brace delimited.&nbsp; 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.
  <br>
_______________________________________________
  <br>
TeX FAQ: <a class="moz-txt-link-freetext" href="http://www.tex.ac.uk/faq">http://www.tex.ac.uk/faq</a>
  <br>
Mailing list archives: <a class="moz-txt-link-freetext" href="http://tug.org/pipermail/texhax/">http://tug.org/pipermail/texhax/</a>
  <br>
More links: <a class="moz-txt-link-freetext" href="http://tug.org/begin.html">http://tug.org/begin.html</a>
  <br>
  <br>
Automated subscription management:
<a class="moz-txt-link-freetext" href="http://tug.org/mailman/listinfo/texhax">http://tug.org/mailman/listinfo/texhax</a>
  <br>
Human mailing list managers: <a class="moz-txt-link-abbreviated" href="mailto:postmaster@tug.org">postmaster@tug.org</a>
  <br>
  <br>
</blockquote>
I assume that this has to be done within TeX.&nbsp; Otherwise it is a
function of whatever editor you are using:&nbsp; <br>
<br>
It is a problem I often find, and I use the emacs "narrow-to-region"
command.&nbsp; Find whatever triggers the opening brace,<br>
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.&nbsp; It is very fast indeed.<br>
<br>
The need for this ability to narrow to a specific context is one of the
reasons for providing specific <b>begin</b> and <b>end</b> macros in
many contexts, rather than insisting that the context appear as a macro
parameter.&nbsp; 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.&nbsp;
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.<br>
<br>
Pierre MacKay<br>
</body>
</html>