Similar to Joseph’s, but using less code
\documentclass{article}
\usepackage{xstring}
\newcount\X
\newdimen\stringdepth
\begin{document}
\def\mystring{abcdefgh}
\StrLen{\mystring}[\len]
\X=0
\stringdepth=0pt
\loop
\ifnum\len>\X
\advance\X by 1
\StrChar{\mystring}{\X}[\tmp]%
\begingroup\edef\x{\endgroup
\dimen0=\fontchardp\font`\tmp\relax
}\x
\ifdim\dimen0>\stringdepth \stringdepth=\dimen0 \fi
% just for showing the work
\typeout{\tmp\space has depth \the\dimen0 }%
\repeat
\typeout{Max depth: \the\stringdepth}
\end{document}
Of course
\settodepth{\stringdepth}{\mystring}
is much more efficient.
A different loop, quite flexible, as shown by the examples: the current item is referred to as #1 in the final argument to \stringloop:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\stringloop}{smm}
{
\IfBooleanTF{#1}
{ % we have a macro as argument
\tl_map_inline:Nn #2 { #3 }
}
{ % an explicit token list
\tl_map_inline:nn { #2 } { #3 }
}
}
\ExplSyntaxOff
\newdimen\stringdepth
\begin{document}
\def\mystring{abcdefgh}
\stringloop{abcdefgh}{\typeout{#1 has depth \the\fontchardp\font`#1}}
\stringdepth=0pt
\stringloop*{\mystring}{%
\ifdim\fontchardp\font`#1>\stringdepth
\stringdepth=\fontchardp\font`#1\relax
\fi
}
\typeout{Max depth in \mystring: \the\stringdepth}
\end{document}
Here is the output on the terminal (and log file):
a has depth 0.0pt
b has depth 0.0pt
c has depth 0.0pt
d has depth 0.0pt
e has depth 0.0pt
f has depth 0.0pt
g has depth 1.94444pt
h has depth 0.0pt
Max depth in abcdefgh: 1.94444pt
\StrCharis simpler, isn't it? – egreg Apr 25 '17 at 09:50