This came up from Labels in TikZ are incorrectly interpreted, but it's also something I've run into with the braids package, and a couple of other things I've done. Also, from looking at the TikZ code this is something that TikZ does a lot but I don't see that it does it very elegantly!
The question is this: how do I test for a particular character in the input stream, irrespective of the category code?
The example from the braids package is fairly simple. The package there works by taking a string of the form a_2 a_3^{-1} and so forth. As with TikZ, it detects the end of the braid by looking for the ; character. But some packages, Babel for example, make that active. Frankly, I don't care if ; is active or not: it's just a placeholder for the end of the braid. So I don't want to have to bother testing all the possible variants of catcodes, I just want to know "is it a semi-colon?". I'm in a similar situation with the _ and ^ characters, you might notice.
So is there a robust (whatever that means) way to test: "Is the token that I have right now a semi-colon?".