Here you want to ensure that [
isn't seen as the start of an argument by \bTD
. To do that, the easiest way is to insert a \relax
. As you are making this part of a macro, I'd do that in the definition not each time you pass an argument
\def\tableItem#1#2 {%
\bTR
\bTD\relax #1 \eTD
\bTD\relax #2 \eTD
\eTR
}
\starttext
\bTABLE
\tableItem{Regex}{[\string\w\space]+}
\eTABLE
\stoptext
I suspect you want something like
\tableItem{Regex}{\type{[\w ]+}}
which would avoid the need for the \relax
in this case as \type
will also stop the scanning for a [
, but it's likely best to keep the \relax
anyway.
Working example using edited question: notice that \w
has to be made into a string one way or another
\def\tableHeader#1 {%
\start
\setupTABLE[frame=on,offset=1mm]
\setupTABLE[c][1][width=0.25\textwidth]
\setupTABLE[c][2][width=0.75\textwidth]
\bTABLE
\bTR
\bTH[nc=2] #1 \eTH
\eTR
}
\def\tableFooter {%
\eTABLE
\stop
}
\def\tableItem#1#2 {%
\bTR
\bTD\relax #1 \eTD
\bTD\relax #2 \eTD
\eTR
}
\starttext
\tableHeader{Example}
\tableItem{Regex}{[\string\w\space]+}
\tableFooter
\stoptext
#2
in the definition might be a problem as well as using\w
which looks like a macro but your input suggests it should be verbatim?