How can I check if the value of a variable is the same as what another variable?
Well your question is not simple. At first you didn't explain what you mean by "same for you" so the rules for your "fuzzy" comparision are quite unclear. And at second you didn't explain what content your variables can have. Things can get very difficult if arbitrary TeX-commands are allowed. For your example the following works:
\documentclass{article}
\usepackage{xparse}
\begin{document}
\newcommand\test{Five}
\newcommand\unknown{{{F}I{V}E{}}}
\newcommand\unknownb{Four}
\ExplSyntaxOn
\NewDocumentCommand\aresame { m m }
{
\tl_set_rescan:Nnx \l_tmpa_tl
{
\char_set_catcode_ignore:N \{
\char_set_catcode_ignore:N \}
}
{#1}
\tl_set_rescan:Nnx \l_tmpb_tl
{
\char_set_catcode_ignore:N \{
\char_set_catcode_ignore:N \}
}
{#2}
\tl_set:Nx\l_tmpa_tl {\str_fold_case:V \l_tmpa_tl}
\tl_set:Nx\l_tmpb_tl {\str_fold_case:V \l_tmpb_tl}
\tl_if_eq:NNTF \l_tmpa_tl\l_tmpb_tl {yes} {no}
}
\ExplSyntaxOff
\aresame{\test}{\unknown}
\aresame{\test}{\unknownb}
\end{document}
A (weaker) version of Ulrike's code that works also in TeX Live 2013; the assumption is that <
and >
don't appear in the strings you want to compare.
\documentclass{article}
\makeatletter
\newcommand{\aresame}[2]{%
\aresame@massage\aresame@tempa{#1}%
\aresame@massage\aresame@tempb{#2}%
\ifx\aresame@tempa\aresame@tempb
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\def\aresame@massage#1#2{%
\begingroup\let\@xp\expandafter\let\@nx\noexpand
\everyeof{}%
\catcode`{=9 \catcode`}=9
\catcode`<=1 \catcode`>=2
\begingroup\edef\x{%
\endgroup\@nx\scantokens{\def\@nx\1<#2>\@nx\empty}%
}\x
\uppercase\@xp{\@xp\endgroup\@xp\def\@xp#1\@xp{\1}}%
}
\makeatother
\begin{document}
\def\test{Five}
\def\unknown{{{F}I{V}E{}}}
\def\unknownb{Four}
\def\unknownc{{\unknownb}}
--\aresame{\unknown}{\test}{TRUE}{FALSE}--\par
--\aresame{\test}{\unknown}{TRUE}{FALSE}--\par
--\aresame{\unknownb}{\test}{TRUE}{FALSE}--\par
--\aresame{\unknownb}{Four}{TRUE}{FALSE}--\par
--\aresame{\unknownb}{\unknownc}{TRUE}{FALSE}--\par
\end{document}