In the discussion How does TeX look for delimited arguments? I tried to elaborate on how the processing of delimited and undelimited arguments is done by (La)TeX.
Using delimited arguments you can easily have your \insert-macro—better call it, e.g., \INSERT—as first argument catch an argument which is delimited by an opening-bracket and then a second argument which is delimited by a closing bracket and then feed the first argument to another macro which also uses delimited arguments, for forking depending on whether that first argument
is empty,
is the phrase "this",
is the phrase "that",
is something else.
Defining an environment fancyenvironment can be done, e.g., by means of the framework of the verbatim package.
The verbatim package does provide means for defining environments that do process input line by line and search for the sequence that ends the environment in question.
You can use its framework for within a token-register accumulating input line by line tokenized under verbatim-catcode-régime with an \INSERT-command added at the beginning of each line.
At the end of the environment you can have the content of the token register "flushed" towards \scantokens under normal catcode-régime.
In case you don't have eTeX-extensions available, you can have written the content of the token-register unexpanded to a scratch file and via \input have LaTeX process that scratch file under normal catcode régime.
\documentclass[a4paper]{article}
\usepackage{verbatim}
\makeatletter
%%----------------------------------------------------------------------
\newcommand\UD@firstoftwo[2]{#1}%
\newcommand\UD@secondoftwo[2]{#2}%
\newcommand\UD@PassFirstToSecond[2]{#2{#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>}%
%%
%% Without eTeX-extensions:
%% 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]{%
\romannumeral0\expandafter\UD@secondoftwo\string{\expandafter
\UD@secondoftwo\expandafter{\expandafter{\string#1}\expandafter
\UD@secondoftwo\string}\expandafter\UD@firstoftwo\expandafter{\expandafter
\UD@secondoftwo\string}\expandafter\expandafter\UD@firstoftwo{ }{}%
\UD@secondoftwo}{\expandafter\expandafter\UD@firstoftwo{ }{}\UD@firstoftwo}%
}%
%% With eTeX-extensions:
%\newcommand\UD@CheckWhetherNull[1]{%
% \romannumeral0\if\relax\detokenize{#1}\relax
% \expandafter\UD@firstoftwo\else\expandafter\UD@secondoftwo\fi
% {\expandafter\expandafter\UD@firstoftwo{ }{}\UD@firstoftwo}%
% {\expandafter\expandafter\UD@firstoftwo{ }{}\UD@secondoftwo}%
%}%
%%----------------------------------------------------------------------
%% Check whether argument contains no exclamation mark which is not nested
%% in braces:
%%......................................................................
%% \UD@CheckWhetherNoExclam{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% contains no exclamation mark>}%
%% {<Tokens to be delivered in case that argument
%% contains exclamation mark>}%
%%
\newcommand\UD@GobbleToExclam{}\long\def\UD@GobbleToExclam#1!{}%
\newcommand\UD@CheckWhetherNoExclam[1]{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@GobbleToExclam#1!}%
}%
%%----------------------------------------------------------------------
%% \ThisThatFork grabs the first thing behind a
%% a token-sequence of pattern !!this!that!
%%......................................................................
\newcommand\ThisThatFork{}
\long\def\ThisThatFork#1!!this!that!#2#3!!!!{#2}%
%%----------------------------------------------------------------------
%% Your \insert-macro - better call it \INSERT because \insert is already
%% defined in LaTeX and I strongly recommend not to override that!
%%......................................................................
\newcommand\INSERT{}%
\long\def\INSERT#1[#2]{%
\romannumeral0%
\UD@CheckWhetherNoExclam{#1}{%
\ThisThatFork!#1!this!that!{ empty macro: #2\\}%<-case #1 is empty/has not okens
!!#1!that!{ this macro: #2\\}%<-case #1 = this
!!this!#1!{ that macro: #2\\}%<-case #1 = that
!!this!that!{ something else macro: #2\\}%<-case #1 = something else without exclamation-mark.
!!!!%
}{ something else macro: #2\\}%<-case #1 = something else with exclamation-mark.
}%
%%----------------------------------------------------------------------
%% Your environment fancyenvironment.
%% fancyenvironments cannot be nested within each other.
%% \end{fancyenvironment} should not be indented.
%%......................................................................
\newtoks\UD@scratchtoks
\newwrite\UD@scratchwrite
\newenvironment{fancyenvironment}{}{}%
\def\fancyenvironment{%
\begingroup
\UD@scratchtoks={}%
\let\do\@makeother
\dospecials
\catcode`\^^M\active
\def\verbatim@startline{\verbatim@line{}}%
\def\verbatim@addtoline##1{\verbatim@line\expandafter{\the\verbatim@line##1}}%
\def\verbatim@processline{%
\expandafter\UD@CheckWhetherNull\expandafter{\the\verbatim@line}{}%
{\UD@scratchtoks\expandafter{\the\expandafter\UD@scratchtoks\expandafter\INSERT\the\verbatim@line^^J}}%%
\def\verbatim@processline{%
\UD@scratchtoks\expandafter{\the\expandafter\UD@scratchtoks\expandafter\INSERT\the\verbatim@line^^J}%
}%
}%
\def\verbatim@finish{\expandafter\UD@CheckWhetherNull\expandafter{\the\verbatim@line}{}{\verbatim@processline}}%
\verbatim@
}%
\def\endfancyenvironment{%
% With eTeX-extensions:
% \expandafter\endgroup\expandafter\scantokens\expandafter{\the\expandafter\UD@scratchtoks\@percentchar}%
% Without eTeX-extensions::
\expandafter\endgroup
\expandafter\begingroup
\expandafter\UD@scratchtoks\expandafter{\the\expandafter\UD@scratchtoks\@percentchar}%
\immediate\openout\UD@scratchwrite \jobname.scratchwrite %
\immediate\write\UD@scratchwrite{\the\UD@scratchtoks}%
\immediate\closeout\UD@scratchwrite
\endgroup
\input\jobname.scratchwrite %
}%
\makeatother
\begin{document}
\noindent\verb|\INSERT [test with nothing]|:\\
\INSERT [test with nothing]
\bigskip
\noindent\verb|\INSERT this[test with this]|:\\
\INSERT this[test with this]
\bigskip
\noindent\verb|\INSERT that[test with that]|:\\
\INSERT that[test with that]
\bigskip
\noindent\verb|\INSERT something else[test with something else without !]|:\\
\INSERT something else[test with something else without !]
\bigskip
\noindent\verb|\INSERT !something else![test with something else with !]|:\\
\INSERT !something else![test with something else with !]
\bigskip
\begin{verbatim}
\noindent\begin{fancyenvironment}
this[test]
that[test]
\end{fancyenvironment}
\end{verbatim}
\noindent\begin{fancyenvironment}
this[test]
that[test]
\end{fancyenvironment}
\end{document}

Don't be frightened by the \romannumeral0...-thingie:
This is just a trick for keeping expansion going until having the desired result:
\romannumeral does convert numbers into lowercase-roman notation.
With 0 following the \romannumeral, it is ensured that (La)TeX already found a digit and now keeps on searching for more digits.
While seeking more digits for \romannumeral, (La)TeX will keep expanding expandable tokens.
While seeking more digits for \romannumeral and hereby expanding expandable tokens, (La)TeX will take a space token for the end of the digit-sequence and will silently remove that space token and stop searching for digits.
When (La)TeX has this way gathered all digits of the number, it will convert the number to lowercase roman notation. But it will do that only in case the number found is positive. Otherwise it will just swallow that number, not delivering any token.
Thus you can (ab)use \romannumeral for triggering a lot of expansion-work as long as you ensure that after the expansion-work a non-positive number, e.g. the number 0 is found.
In the discussion How can I know the number of expandafters when appending to a csname macro? I also tried to elaborate on expansion-triggering via \romannumeral.
\insert- at least if you like footnotes. – moewe Jan 08 '19 at 11:06