# Deactivating an active character

How do I deactivate an active character? The following works without the activizations in the preamble, but not with them, in spite of my attempt to reset the catcode of : to 12.

\documentclass{article}

\catcode:=\active \def:{\,\string:}
\catcode!=\active \def!{\,\string!}

\begin{document}

Tom went on whitewashing---paid no attention to the steamboat. Ben stared
a moment and then said: \emph{Hi-Yi! You're} up a stump, ain't you!'
\catcode\:=12
\label{not:to:be:typeset}

\end{document}

• \label{not\string:to\string:be\string:typeset} – egreg Aug 16 '17 at 12:11
• Better: use babel features. – egreg Aug 16 '17 at 12:17
• The label is stored in a the aux-file and read back at \begin{document}, so you should pay attention at the catcode values there too. – Ulrike Fischer Aug 16 '17 at 12:19
• @egreg, which babel features? – Toothrot Aug 16 '17 at 12:46
• @egreg, I suppose one could use l3regex to replace all occurrences of : inside \label with \string:, unless there is a better way. – Toothrot Aug 16 '17 at 12:53