[texhax] Last char of a string

Herbert Voss Herbert.Voss at FU-Berlin.DE
Thu Jul 7 15:21:18 CEST 2011


Am 07.07.2011 15:05, schrieb Michael Barr:
> Is there any easy way to find the last character of a string?
>
> Why? Well the online journal I do the tex editing for uses runin
> subsection titles. They have to end with a period or other punctuation.
> So I want to look at the last character of the title and add a period
> unless it already is a period (or question mark or even an exclamation
> point).

\documentclass{article}
\usepackage{xstring}
\begin{document}

\IfEndWith{My title with a dot}{.}{ends with dot}{ends not with a dot}

\def\Title{My title with a dot.}
\IfEndWith{\Title}{.}{ends with a dot}{ends not with a dot}

\end{document}

Herbert


More information about the texhax mailing list