<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __sub(self, string: str = '') -> str: """Replace spaces in string. :param string: String. :return: String without spaces. """

        replacer = self.random.choice(['_', '-'])
        return re.sub(r'\s+', replacer, string.strip())