Question: I have a simple macro that I want to define as

```
\newcommand{\myalert}[1]{\textcolor{red}{ALERT: #1}}

```

However, I want to have a conditional such that if #1 is one of two strings (say "noalert" and "null"), then the macro is instead equivalent to ignoring #1 and eating it up:

```
\newcommand{\myalert}[1]{}

```

I am not sure to what extent such conditionals are allowed in latex in defining commands.

Answer: 
Here is a possibility using `\str_case:nnF`:

```
\documentclass{article}
\usepackage{xcolor}

\ExplSyntaxOn

\NewDocumentCommand \myalert { m }
  {
    \str_case:nnF {#1}
      {
        { noalert } { }
        { null } { }
      }
      { \textcolor{red}{ALERT:~#1} }
  }

\ExplSyntaxOff

\begin{document}

\noindent
\myalert{fire!}\\
\myalert{water!}\\
X\myalert{noalert}\myalert{null}X\\
\myalert{earthquake!}

\end{document}

```

[![enter image description here](https://i.stack.imgur.com/N9vVM.png)](https://i.stack.imgur.com/N9vVM.png)

The same without the `expl3` category codes, in case you are uncomfortable with them:

```
\documentclass{article}
\usepackage{xcolor}

\ExplSyntaxOn
\cs_new_eq:NN \strcasennF \str_case:nnF
\ExplSyntaxOff

\NewDocumentCommand \myalert { m }
  {%
    \strcasennF {#1}
      {
        {noalert} {}
        {null} {}
      }
      {\textcolor{red}{ALERT: #1}}%
  }

\begin{document}

\noindent
\myalert{fire!}\\
\myalert{water!}\\
X\myalert{noalert}\myalert{null}X\\
\myalert{earthquake!}

\end{document}

```
With pure (La)TeX:

```
\documentclass{article}
\usepackage{xcolor}

\newcommand{\myalert}[1]{%
    \def\compareA{#1}%
    \def\compareB{noalert}%
    \def\compareC{null}%
    \ifx\compareA\compareB\else%
        \ifx\compareA\compareC\else%
            \textcolor{red}{ALERT: #1}%
        \fi%
    \fi%
}

\begin{document}

\myalert{hello}

\myalert{null}

\myalert{noalert}

\myalert{bye}

\end{document}

```

[![enter image description here](https://i.stack.imgur.com/VLT79.png)](https://i.stack.imgur.com/VLT79.png)