espnet2.utils.types.remove_parenthesis
Less than 1 minute
espnet2.utils.types.remove_parenthesis
espnet2.utils.types.remove_parenthesis(value: str)
Removes parentheses or brackets from the beginning and end of a string.
This function checks if the input string value starts and ends with parentheses () or brackets []. If so, it removes them and returns the modified string. If the input string does not have these characters at both ends, it returns the string unchanged.
- Parameters:value (str) – The input string from which to remove parentheses or brackets.
- Returns: The input string with outer parentheses or brackets removed.
- Return type: str
Examples
>>> remove_parenthesis("(example)")
'example'
>>> remove_parenthesis("[example]")
'example'
>>> remove_parenthesis("example")
'example'
>>> remove_parenthesis(" (example) ")
'example'