[Tex/LaTex] have a curly brace as macro argument delimiter

delimitersmacros

Is there any trick that allows to have a { in argument delimiters of a macro ?
for example, with this definition :

\def\start#1\fin{+++#1+++}

the call

\start coucou\fin{3}4

will display

+++coucou+++34

because \fin is the right delimiter of the argument of the macro \start. Now, i would like the whole \fin{3} to be the delimiter. So that the same call as above would now output:

+++coucou+++4

The problem is how to include the curly brace in the delimiters.

Edit1 In particular, I would like the following call

\start coucou\fin{2}blabla\fin{3} 

to "output"

coucou\fin{2}blabla

but, regarding to David's comments, it seems to be impossible.

Best Answer

If the arguments to \fin are simple numbers, you can check whether the argument is 3; here's a Plain TeX version (put the standard things to make it into LaTeX).

\def\start{+++\startaux}
\def\startaux#1\fin#2{%
  #1%
  \ifnum#2=3
    +++%
  \else
    \fin{#2}%
    \expandafter\startaux
  \fi
}
\def\fin#1{-#1-}

\start cocou\fin{3}

\start cocou\fin{2}blabla\fin{3}

\bye

enter image description here