diff --git a/code_to_optimize/remove_control_chars.py b/code_to_optimize/remove_control_chars.py new file mode 100644 index 000000000..45f67459e --- /dev/null +++ b/code_to_optimize/remove_control_chars.py @@ -0,0 +1,10 @@ +import re + + +class CharacterRemover: + def __init__(self): + self.version = "0.1" + + def remove_control_characters(self, s) -> str: + """Remove control characters from the string.""" + return re.sub("[\\x00-\\x1F\\x7F]", "", s) if s else ""