# Problem with str_if_eq

This must be a really dumb question, but what am i doing wrong here? As far as I can see, the strings are equal, so the test should be successful, instead i get not successful.

\documentclass{article}

\ExplSyntaxOn

\str_new:N \g_test_str

\NewDocumentCommand{\Test}{m}
{
\str_set:Nn \g_test_str { #1 }

\noindent
Input is #1 \newline
String is \g_test_str \newline
\str_if_eq:nnTF { \g_test_str }{test}{test successful}{test not successful}
}

\ExplSyntaxOff

\begin{document}

\Test{test}

\end{document}


Thanks for any help

You need the V variant to receive the contents of a variable:

\documentclass{article}

\ExplSyntaxOn

\str_new:N \l_test_str

\NewDocumentCommand {\Test} {m} {
\str_set:Nn \l_test_str {#1}
\noindent
Input~ is~ #1 \newline
String~ is~ \l_test_str \newline
\str_if_eq:VnTF \l_test_str {test} {test~ successful} {test~ not~ successful}
}
\ExplSyntaxOff

\begin{document}

\Test{test}

\end{document}


Otherwise the unexpanded strings “\l_test_str” and “test” are compared which are not equal.

I also renamed your variable as it is a local one here and not a global one.

• Thank you very much. Jan 31 at 21:49