\documentclass[pdftex,a4paper,12pt,oneside]{book}%
\usepackage{xstring}
\begin{document}
\newcommand{\tmpa}{}
\newcommand{\tmpb}{}
\newcommand{\tmpc}{}
\renewcommand{\tmpc}{abcdefg} \noindent tmpc: \tmpc \\
\renewcommand{\tmpa}{\meaning\tmpc} tmpa: \tmpa \\
len: \StrLen{\tmpa} \\
char(20): \StrChar{\tmpa}{20}[\tmpb] \tmpb \\
pos(f): \StrPosition{\tmpa}{f}
\end{document}
Result:
tmpc: abcdefg
tmpa: \long macro:->abcdefg
len: 21
char(20): f
pos(f): 0
Why? tmpa obviously contains character 'f' on the position of 20 as we can find it with \StrChar. But that 'f' not the same as the one we are trying to find with StrPos. I thought about catcode differences, but did not find anything usable (I might be wrong with changing catcode of 'f' before searching for it).
\string fis clear but how can I use\stringbefore a macro? e.g.\string\mymacroresults in "\mymacro" – pmks Apr 16 '12 at 07:42\markright(counter value and sectionname) and try to get them back using\StrBetween{\firstmark}{{\delim}{\delim}but with package babel\firstmarkis full of macros and\StrBetweencan not cope with them. So I use\StrBetween{\meaning\firstmark}...and decently get my values. With accented chars andinputencI get coded strings like this in my output:\IeC {\’\i }\’a\H o\’o\"u\"o. I thought that it might help to change (’) to (') and I used\StrSubstituteand run into this problem. After all, now I can change normal chars but no (’) :( – pmks Apr 16 '12 at 13:51