# Macro with different font for subscript and superscript text

I need to define a macro, lets call it DifferentFontMacro, that takes a single string x as input. This string x is of the form {string1}^{string2}\_{string3}. Now, I want the output of this macro to be {string1}^{\mathsf{string2}}_{\mathsc{string3}}. One approach that I could find is using the xstring package to extract string1, string2 and string3 from x, and then outputting the desired output. However, it seems cumbersome, and I don't know if there's a better solution.

Thanks.

• Will you always have the subscript and superscript and in that specific order (superscript followed by subscript)? If so, one could use a delimited parameter text to extract the content... – Werner Jan 4 '16 at 21:10
• do you mean \mathsc (which is not defined by default) – David Carlisle Jan 4 '16 at 21:41

\documentclass{article}
$\zzz{{string1}^{string2}\_{string3}}$