get rid of global
fix case sensitivity bug; unicode/localized regexp
python 3 discourages re.L
docstrings