I try to define a macro taking as an argument either a number or a colon-delimited range of numbers, e.g. \macro{3.14} or \macro{2:5}. I can parse the colon easily using a simple trick:
\def\macro#1{ \def\m@gic##1:##2:##3\end{\ifx ##3:\relax Two arguments (##1,##2)\else One argument (##1)\fi}\m@gic #1::\end} However, calling such a macro fails when French babel is loaded, because it makes the colon an active character. Undaunted, I write a second macro for that case:
\begingroup\catcode`\:=\active \def\macro@active#1{ % same contents... } \endgroup and can now decide at call-time, depending on the value of \the\catcode\`:, which macro to call.
However, the situation becomes even more complex! It so occurs that \macro may take a default value, which might be defined before the babel package is loaded, and thus might have a normal colon character: something like this
\def\macrodefault{\macro{1:2}} % with normal category colon... \usepackage[french]{babel} % ... but now it is active. (This situation is out of my control and I cannot just swap the two lines). So now I want the \macro expansion to be able to parse both types of colon, either active or normal. Is there a simple way to do this? Maybe re-parse the #1 in a \toks register? or use some \lccode trick? (A simple \afterassignment will not do it, since I cannot expect the numbers to be integers).

thm:foooritem:thm:foo:a. And it does work with french babel.