With \def\testast#1{\ifx*#1\relax YES\else NO\fi} the command
\testast{*Word}%
yields:
\ifx**Word\relax YES\else NO\fi.
\ifx compares the meaning of * to the meaning of *. Thus the if-branch is taken while the \else-branch is skipped while the if-branch is formed by Word\relax YES. \relax does not yield anything visible in the .pdf-file, thus in the .pdf-file you see WordYES.
\makeatletter
%%=============================================================================
%% Paraphernalia:
%% \UD@firstoftwo, \UD@secondoftwo, \UD@Exchange, \UD@stopromannumeral,
%% \UD@CheckWhetherNull, \UD@CheckWhetherLeadingTokens
%%=============================================================================
\newcommand\UD@firstoftwo[2]{#1}%
\newcommand\UD@secondoftwo[2]{#2}%
\newcommand\UD@Exchange[2]{#2#1}%
\@ifdefinable\UD@stopromannumeral{\chardef\UD@stopromannumeral=`\^^00}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% \UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's \ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
\newcommand\UD@CheckWhetherNull[1]{%
\romannumeral\expandafter\UD@secondoftwo\string{\expandafter
\UD@secondoftwo\expandafter{\expandafter{\string#1}\expandafter
\UD@secondoftwo\string}\expandafter\UD@firstoftwo\expandafter{\expandafter
\UD@secondoftwo\string}\expandafter\UD@stopromannumeral\UD@secondoftwo}{%
\expandafter\UD@stopromannumeral\UD@firstoftwo}%
}%
%%=============================================================================
%% Check whether argument's leading tokens form a specific
%% token-sequence that does not contain explicit character tokens of
%% category 1 or 2 or 6:
%%=============================================================================
%% \UD@CheckWhetherLeadingTokens{<argument which is to be checked>}%
%% {<a <token sequence> without explicit
%% character tokens of category 1 or 2
%% or 6>}%
%% {<internal token-check-macro>}%
%% {<tokens to be delivered in case
%% <argument which is to be checked> has
%% <token sequence> as leading tokens>}%
%% {<tokens to be delivered in case
%% <argument which is to be checked>
%% does not have <token sequence> as
%% leading tokens>}%
\newcommand\UD@CheckWhetherLeadingTokens[3]{%
\romannumeral\UD@CheckWhetherNull{#1}%
{\expandafter\UD@stopromannumeral\UD@secondoftwo}%
{%
% Let's nest things into \UD@firstoftwo{...}{} to make sure they are nested in braces
% and thus do not disturb when the test is carried out within \halign/\valign:
\expandafter\UD@firstoftwo\expandafter{%
\expandafter\expandafter\expandafter\UD@stopromannumeral
\romannumeral
\expandafter\UD@secondoftwo\string{\expandafter\UD@@CheckWhetherLeadingTokens#3{\relax}#1#2}{}}{}%
}%
}%
\newcommand\UD@@CheckWhetherLeadingTokens[1]{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@firstoftwo{}#1}%
{\UD@Exchange{\UD@firstoftwo}}{\UD@Exchange{\UD@secondoftwo}}%
{\expandafter\expandafter\expandafter\UD@stopromannumeral
\expandafter\expandafter\expandafter}%
\expandafter\UD@secondoftwo\expandafter{\string}%
}%
%%-----------------------------------------------------------------------------
%% \UD@internaltokencheckdefiner{<internal token-check-macro>}%
%% {<token-sequence-gobble-macro>}%
%% {<token sequence>}%
%% Defines <internal token-check-macro> to snap everything
%% until reaching <token sequence>-sequence and spit that out
%% nested in braces.
%%
%% Defines <token-sequence-gobble-macro> to remove <token sequence> which in the
%% token-stream must definitely follow the token <token-sequence-gobble-macro>.
%%-----------------------------------------------------------------------------
\newcommand\UD@internaltokencheckdefiner[3]{%
\@ifdefinable#1{\long\def#1##1#3{{##1}}}%
\@ifdefinable#2{\def#2#3{}}%
}%
%%=============================================================================
%% Define infrastructure for checking for a leading *:
%%=============================================================================
\UD@internaltokencheckdefiner{\UD@SnapToStar}{\UD@GobbleStar}{*}%
%
% Now you can check for a leading * via
%
% \UD@CheckWhetherLeadingTokens{<argument to check>}{*}{\UD@SnapToStar}%
% {<tokens in case <argument to check> has a leading *>}%
% {<tokens in case <argument to check> does not have a leading *>}%
%
% \UD@GobbleStar must be trailed by * and removes that *.
%%=============================================================================
%% Define infrastructure for checking for a leading sequence *<space token>:
%%=============================================================================
\UD@internaltokencheckdefiner{\UD@SnapToStarSpace}{\UD@GobbleStarSpace}{* }%
%
% Now you can check for a leading sequence *<space token> via
%
% \UD@CheckWhetherLeadingTokens{<argument to check>}{* }{\UD@SnapToStarSpace}%
% {<tokens in case <argument to check> has a leading *<space token> >}%
% {<tokens in case <argument to check> does not have a leading *<space token> >}%
%
% \UD@GobbleStarSpace must be trailed by a sequence *<space token>
% and removes that sequence *<space token>.
%%=============================================================================
%% Check if first token of macro-argument is an asterisk:
%%=============================================================================
%%
%% \testast{<argument to check>}%
%% {<tokens in case <argument to check> has a leading *>}%
%% {<tokens in case <argument to check> does not have a leading *>}%
%%
%% (I suggest naming the command \CheckWhetherLeadingAsterisk instead of
% \testast.)
%%
\newcommand\testast[1]{%
\UD@CheckWhetherLeadingTokens{#1}{*}{\UD@SnapToStar}%
}%
%------------------------------------------------------------------------------
\makeatother
\documentclass{article}
\usepackage{getitems}
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\usepackage{amsmath}
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\makeatletter
\NewEnviron{multi}[1][]{%
\expandafter\gatheritems\expandafter{\BODY}%
\loopthroughitemswithcommand{\findcorrect}%
}{}%
\newcommand\findcorrect[1]{%
\UD@CheckWhetherLeadingTokens{#1}{}{\UD@SnapToStar}{%
\expandafter\gdef\expandafter\NumberOfCorrectAnswer\expandafter{%
\number\value{currentitemnumber}%
}%
\UD@CheckWhetherLeadingTokens{#1}{ }{\UD@SnapToStarSpace}{%
\expandafter\gdef\expandafter\TextOfCorrectAnswer\expandafter{\UD@GobbleStarSpace#1}%
}{%
\expandafter\gdef\expandafter\TextOfCorrectAnswer\expandafter{\UD@GobbleStar#1}%
}%
}{}%
}%
\makeatother
\begin{document}
\verb|\testast{Word}{YES}{NO}|: \testast{Word}{YES}{NO}
\verb|\testast{Word}{YES}{NO}|: \testast{Word}{YES}{NO}
\begin{multi}
Text---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\item Answer---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\item Another answer---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\item* Correct---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\end{multi}
The number of the correct answer is: \NumberOfCorrectAnswer.
The text of the correct answer is: \TextOfCorrectAnswer.
\end{document}

If you need counting of your multi-environments and extracting answers etc as specified in your comment
In fact I was about to asking :) there is a counting running, so I need to extract the text of questions, the possible answers, and the correct one. In what is my attempt, the counter is numes, then I use \csname TEXT\roman{numes} for the text \csname POSS\roman{numes} for the number of possible answers, \csname ANSWER\roman{n}ES\roman{numes} for the nth possible answer, and \csname CORRECT\roman{numes} for the number of correct choice. Then I use such macros for formatting exams, so I need to use then say like \expandafter\def\myneededmacro\cnsame TEXT\roman{numes}\endcsname
, then you can do something like the following where I use \UD@CsNameToCsToken for avoiding having even longer \expandafter-chains for generating control-sequence-tokens from control-sequence-names:
\makeatletter
%%=============================================================================
%% Paraphernalia:
%% \UD@firstoftwo, \UD@secondoftwo, \UD@Exchange, \UD@stopromannumeral,
%% \UD@CsNameToCsToken, \UD@CheckWhetherNull, \UD@CheckWhetherLeadingTokens
%%=============================================================================
\newcommand\UD@firstoftwo[2]{#1}%
\newcommand\UD@secondoftwo[2]{#2}%
\newcommand\UD@Exchange[2]{#2#1}%
\@ifdefinable\UD@stopromannumeral{\chardef\UD@stopromannumeral=`\^^00}%
%%-----------------------------------------------------------------------------
%% Obtain control sequence token from name of control sequence name:
%%-----------------------------------------------------------------------------
%% \CsNameToCsToken<stuff not in braces>{NameOfCs}
%% -> <stuff not in braces>\NameOfCs
%% (<stuff not in braces> may be empty.)
\@ifdefinable\UD@CsNameToCsToken{%
\long\def\UD@CsNameToCsToken#1#{\romannumeral\UD@@CsNameToCsToken{#1}}%
}%
\newcommand\UD@@CsNameToCsToken[2]{%
\expandafter\UD@Exchange\expandafter{\csname#2\endcsname}{\UD@stopromannumeral#1}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% \UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's \ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
\newcommand\UD@CheckWhetherNull[1]{%
\romannumeral\expandafter\UD@secondoftwo\string{\expandafter
\UD@secondoftwo\expandafter{\expandafter{\string#1}\expandafter
\UD@secondoftwo\string}\expandafter\UD@firstoftwo\expandafter{\expandafter
\UD@secondoftwo\string}\expandafter\UD@stopromannumeral\UD@secondoftwo}{%
\expandafter\UD@stopromannumeral\UD@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument's leading tokens form a specific
%% token-sequence that does not contain explicit character tokens of
%% category 1 or 2 or 6:
%%.............................................................................
%% \UD@CheckWhetherLeadingTokens{<argument which is to be checked>}%
%% {<a <token sequence> without explicit
%% character tokens of category 1 or 2
%% or 6>}%
%% {<internal token-check-macro>}%
%% {<tokens to be delivered in case
%% <argument which is to be checked> has
%% <token sequence> as leading tokens>}%
%% {<tokens to be delivered in case
%% <argument which is to be checked>
%% does not have <token sequence> as
%% leading tokens>}%
\newcommand\UD@CheckWhetherLeadingTokens[3]{%
\romannumeral\UD@CheckWhetherNull{#1}%
{\expandafter\UD@stopromannumeral\UD@secondoftwo}%
{%
% Let's nest things into \UD@firstoftwo{...}{} to make sure they are nested in braces
% and thus do not disturb when the test is carried out within \halign/\valign:
\expandafter\UD@firstoftwo\expandafter{%
\expandafter\expandafter\expandafter\UD@stopromannumeral
\romannumeral
\expandafter\UD@secondoftwo\string{\expandafter\UD@@CheckWhetherLeadingTokens#3{\relax}#1#2}{}}{}%
}%
}%
\newcommand\UD@@CheckWhetherLeadingTokens[1]{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@firstoftwo{}#1}%
{\UD@Exchange{\UD@firstoftwo}}{\UD@Exchange{\UD@secondoftwo}}%
{\expandafter\expandafter\expandafter\UD@stopromannumeral
\expandafter\expandafter\expandafter}%
\expandafter\UD@secondoftwo\expandafter{\string}%
}%
%%-----------------------------------------------------------------------------
%% \UD@internaltokencheckdefiner{<internal token-check-macro>}%
%% {<token-sequence-gobble-macro>}%
%% {<token sequence>}%
%% Defines <internal token-check-macro> to snap everything
%% until reaching <token sequence>-sequence and spit that out
%% nested in braces.
%%
%% Defines <token-sequence-gobble-macro> to remove <token sequence> which in the
%% token-stream must definitely follow the token <token-sequence-gobble-macro>.
%%-----------------------------------------------------------------------------
\newcommand\UD@internaltokencheckdefiner[3]{%
\@ifdefinable#1{\long\def#1##1#3{{##1}}}%
\@ifdefinable#2{\def#2#3{}}%
}%
%%=============================================================================
%% END OF PARAPHERNALIA
%%=============================================================================
%%=============================================================================
%% CHECKING FOR LEADING ASTERISK OR LEADING ASTERISK TRAILED BY AN EXPLICIT
%% SPACE TOKEN
%%=============================================================================
%% Define infrastructure for checking for a leading *:
%%-----------------------------------------------------------------------------
\UD@internaltokencheckdefiner{\UD@SnapToStar}{\UD@GobbleStar}{*}%
%
% Now you can check for a leading * via
%
% \UD@CheckWhetherLeadingTokens{<argument to check>}{*}{\UD@SnapToStar}%
% {<tokens in case <argument to check> has a leading *>}%
% {<tokens in case <argument to check> does not have a leading *>}%
%
% \UD@GobbleStar must be trailed by * and removes that *.
%%-----------------------------------------------------------------------------
%% Define infrastructure for checking for a leading sequence *<space token>:
%%-----------------------------------------------------------------------------
\UD@internaltokencheckdefiner{\UD@SnapToStarSpace}{\UD@GobbleStarSpace}{* }%
%
% Now you can check for a leading sequence *<space token> via
%
% \UD@CheckWhetherLeadingTokens{<argument to check>}{* }{\UD@SnapToStarSpace}%
% {<tokens in case <argument to check> has a leading *<space token> >}%
% {<tokens in case <argument to check> does not have a leading *<space token> >}%
%
% \UD@GobbleStarSpace must be trailed by a sequence *<space token>
% and removes that sequence *<space token>.
%%=============================================================================
%% END OF CHECKING FOR LEADING ASTERISK OR LEADING ASTERISK TRAILED BY AN
%% EXPLICIT SPACE TOKEN
%%=============================================================================
\makeatother
\documentclass{article}
\usepackage{getitems}
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\usepackage{amsmath}
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\makeatletter
\newcounter{numes}%
\NewEnviron{multi}{%
\stepcounter{numes}%
% Instead of counting and defining \NameOfThisMultiInstance from the counter,
% you can have the multi-environment process a mandatory argument where the
% user is to pass a unique name for the current instance of the environment
% and define \NameOfThisMultiInstance from that.
\expandafter\gatheritems\expandafter{\BODY}%
\UD@CsNameToCsToken@ifdefinable{TEXT\roman{numes}}{%
\UD@CsNameToCsToken
\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\gdef
\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter{TEXT\roman{numes}}%
\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter{%
\gathereditem{0}%
}%
}%
\UD@CsNameToCsToken@ifdefinable{POSS\roman{numes}}{%
\UD@CsNameToCsToken
\expandafter\gdef\expandafter{POSS\roman{numes}}\expandafter{%
\number\value{numgathereditems}%
}%
}%
\loopthroughitemswithcommand{\extractanswers}%
}{}%
\newcommand\extractanswers[1]{%
\UD@CheckWhetherLeadingTokens{#1}{}{\UD@SnapToStar}{%
\UD@CsNameToCsToken@ifdefinable{CORRECTNUM\roman{numes}}{%
\UD@CsNameToCsToken
\expandafter\gdef\expandafter{CORRECTNUM\roman{numes}}\expandafter{%
\number\value{currentitemnumber}%
}%
}%
\UD@CsNameToCsToken@ifdefinable{ANSWER\roman{currentitemnumber}ES\roman{numes}}{%
\UD@CheckWhetherLeadingTokens{#1}{ }{\UD@SnapToStarSpace}{%
\UD@Exchange{\expandafter{\UD@GobbleStarSpace#1}}%
}{%
\UD@Exchange{\expandafter{\UD@GobbleStar#1}}%
}%
{%
\UD@CsNameToCsToken
\expandafter\gdef\expandafter
{ANSWER\roman{currentitemnumber}ES\roman{numes}}%
}%
}%
\UD@CsNameToCsToken@ifdefinable{CORRECTTEXT\roman{numes}}{%
\UD@CsNameToCsToken\UD@CsNameToCsToken
\global\let{CORRECTTEXT\roman{numes}}={ANSWER\roman{currentitemnumber}ES\roman{numes}}%
}%
}{%
\UD@CsNameToCsToken@ifdefinable{ANSWER\roman{currentitemnumber}ES\roman{numes}}{%
\UD@CsNameToCsToken\gdef{ANSWER\roman{currentitemnumber}ES\roman{numes}}{#1}%
}%
}%
}%
\makeatother
\begin{document}
\begin{multi}
Header---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\item First answer/incorect---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\item Second answer/incorect---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\item* Third answer-correct---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\item Fourth answer/incorect---$\begin{pmatrix} a&b\c&d\end{pmatrix}$
\end{multi}
\verb|\TEXTi| yields: \TEXTi.
\verb|\POSSi| yields: \POSSi.
\verb|\CORRECTNUMi| yields: \CORRECTNUMi.
\verb|\CORRECTTEXTi| yields: \CORRECTTEXTi
\verb|\ANSWERiESi| yields: \ANSWERiESi.
\verb|\ANSWERiiESi| yields: \ANSWERiiESi.
\verb|\ANSWERiiiESi| yields: \ANSWERiiiESi.
\verb|\ANSWERivESi| yields: \ANSWERivESi.
\end{document}

\@ifstar{yes}{no}is what latex uses for*forms of commands. – David Carlisle May 14 '22 at 11:09\gathererditem{n}which is what comes after the nth occurrence of\item, so it starts by*if we have\item*. So the string I need to test does not contain anymore the command\item– user126154 May 14 '22 at 11:20