If you are needing a way to identify conventional bans, versus bans prefixed with flags, I would check if the first character of the banmask matches none of: A-Z a-z ][}{\|^`_- ?* 0-9 and possibly: . : /

In theory, ban flag prefixes are not going to use any of the following: Qualified nickname characters nor Wildcard characters. Possibly wouldn't use qualified DNS characters '.' and ':' (though '~' is found in ident). Probably wouldn't use '/'.

Charybdis uses '$', and UnrealIRCd uses '~' for its flag prefixes. Let's just start by assuming these are the only possibilities for abnormal ban address masks that might require special handling or case sensitivity.