Question: I want to declare a variable in class that takes in the font name from the preamble of the `TeX` file. 
Something like `\docFont{<Variable>}`. Is there a command that could nullify the space key in latex? For example `\docFont{ Arial }` would return the same result as `\docFont{Arial}`.

My `myclass.cls` File is something like this:

```
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2019/04/09 Standard HomeWork Template]
\LoadClass[a4paper,12pt,onecolumn,final]{article}
\RequirePackge{etoolbox}
\def\hFont#1{\gdef\@hFont{#1}}
\def\@hFont{\@latex@warning@no@line{No \noexpand\hFont given}}
\BeforeBeginEnvironment{document}{
\RequirePackage{xepersian}
\settextfont{\@hFont}
}

```

And my `*.Tex` file is something like this:

```
\documentclass{myclass}
\hFont{Arial}   %Document Persian Font
\begin{document}
something
\end{document}

```

Answer: 
Here, I preprocess the argument to `\docfont` and pass the result to `\docfontcore`, which solely for the purposes of demonstration, detokenizes its argument, so that you can see that it gives the originally specified tokens, trimmed of leading and trailing (but not intermediate) spaces.

The last MWE example shows that passing macros poses no impediment to the approach.

```
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{listofitems}
\newcommand\docfont[1]{%
  \setsepchar{!!!!}% USE SOMETHING NOT IN THE FONTNAMES
  \readlist*\trimmedvar{#1}%
  \itemtomacro\trimmedvar[1]\thetrimmedvar%
  \expandafter\docfontcore\expandafter{\thetrimmedvar}%
}
\newcommand\docfontcore[1]{[\detokenize{#1}]}
\begin{document}
\docfont{ Arial Bold }
\docfont{Arial Bold  }
\docfont{Arial Bold}

\newcommand\myfont{Palatino}
\docfont{ \myfont-oblique }
\end{document}

```

[![enter image description here](https://i.stack.imgur.com/MjAfr.jpg)](https://i.stack.imgur.com/MjAfr.jpg)
My two cents in pure TeX (no packages required):

```tex
\makeatletter
\long\gdef\@calc@trim< #1 >\@/< #2 >\@/< #3 >\@/< #4 >\@/< #5 >\@/< #6 >\@/< #7 >\@/< #8 >\@/< #9 >\@nihil{%
    \ifcase\numexpr2#3#8\relax\or#2\or#7\or#5\or#1\or#1\fi%
}

\long\gdef\trim#1{%
    \@calc@trim< #1 >\@/< #1>\@/< - >\@/< + >\@/< ? >\@/<#1 >\@/<#1>\@/< 0 >\@/< 2 >\@/< 1 >\@/< 3 >\@/< 2 >\@/< ! >\@nihil%
}
\makeatother

```

Test:

```tex
[\trim{ Arial }]

[\trim{ Arial}]

[\trim{Arial }]

[\trim{Arial}]

[\trim{     }]

[\trim{}]

```

Result:

[![Result for \trim](https://i.stack.imgur.com/KCpHi.png)](https://i.stack.imgur.com/KCpHi.png)