Rule 2: Electrolysis and halogens
If the solution on which electrolysis is being performed contains a halogen (such as chlorine and bromine), then the halogen will always form at the anode. If there is no halogen in the solution, then oxygen is formed at the anode.
Halogen > oxygen > all other negatively-charged ions