# How to skip first letters from \jobname in plain Tex

As intentioned in the title I want a macro \skipfirstletters in plain-TeX, that skips the first letters (catcode 11) from the \jobname. For instance if the TeX-file is named Test0xy.tex it should expand to just 0xy.

I tried the following lines as Test0xy.tex:

\def\skipfirstletters#1{\ifcat A#1\expandafter\skipfirstletters\else#1\fi}
\skipfirstletters Test0xy\par
\skipfirstletters\jobname\par
\expandafter\skipfirstletters\jobname

\bye


The result is just

I don't understand alot, e.g. why the expanded \jobname in Line 4 (is it expanded before \skipfirstletters?) does not behave like the plain tokens in Line 2.

I want to use the expanded macro as argument for others if this matters.

Thanks a lot to the community and sorry for my poor knowledge of TeX.

• the tokens in jobname are all catcode 12 or 10 – David Carlisle Apr 10 '18 at 9:07
• 12 ok, but why 10? i thought catcode 10 means "spaces"... – user3330187 Apr 10 '18 at 9:10
• If a space character somehow creeps in \jobname, its category code will be 10. – egreg Apr 10 '18 at 9:12
• All characters in \jobname have catcode 12 (other) to avoid trouble with special characters like \ or % in it. The only exception is the space. I guess this is because file name strings once saved internally do not have catcodes anymore, as there are not material to be typeset but to be used internally. If you reinsert them into the typeset content a neutral catcode is selected to be on the save side, I guess. The TeXBook surely states the reason. – Martin Scharrer Apr 10 '18 at 9:29

the tokens in \jobname are like \string and have catcode 12 (or 10 if it is a space), however you can still test the catcode settings for the slots to test whether it is a letter or not:
\def\skipfirstletters#1{%
\ifnum11=\catcode#1 \expandafter\skipfirstletters\else#1\fi}
`