# String manipulation in xstring

I'm trying to make a string manipulation by using xstring package.

Fore example \myparam equals to this: 1.1 Optimal solution of RNASP

But string functions doesn't work. For example \StrLeft{\myparam}{10} gives this error: Missing control sequence inserted. ...RNASP.\relax }}{10}{figure.caption.8}

I set this: \def\myparamDet{\detokenize{myparam}}

\myparamDet equals to this: \hyper@linkstart {link}{\Hy@tocdestname }{\numberline {1.1}{\ignorespaces Optimal solution of RNASP.\relax }}\hyper@-linkend

After detokenize this works: \StrLeft{\myparamDet}{10} and result is \hyper@lin

So I need two things:

• Getting 1.1 from myparam and setting it to a new variable
• Removing 1.1 from myparam
• With the \detokenize, you discover what \myparam really equals, and it is not a string, but rather a hyperlink macro with various arguments set. Can you indicate whether the intended use will always be for such hyperlinks? – Steven B. Segletes Jun 4 '18 at 18:53
• You really need to provide a small compiling example that highlights the issue. – Steven B. Segletes Jun 4 '18 at 18:57
• Is result of detokenize not sufficient ? I suppose it is an escaped version of the hyperlink macro. Yes this manipulation will only be used for this type of strings. – Mark Jun 4 '18 at 19:06

With the \detokenize, you discover what \myparam really equals, and it is not a string, but rather a hyperlink macro with various arguments set. So you need to set up helper macros to grab the right argument and subargument from the list.

\documentclass{article}
\usepackage{hyperref}
\makeatletter