#!/usr/bin/env python # -*- coding: utf-8 -*- import logging import re logger = logging.getLogger(__name__) ascii_characters = [chr(i) for i in range(32, 127)] ascii_char_rgx = re.compile("{}".format(re.escape(ascii_characters))) def ascii_only(incoming_string): return control_char_rgx.sub("", incoming_string)