diff --git a/voussoirkit/stringtools.py b/voussoirkit/stringtools.py index bc188e0..88ca349 100644 --- a/voussoirkit/stringtools.py +++ b/voussoirkit/stringtools.py @@ -1,23 +1,23 @@ import re import unicodedata -def collapse_whitespace(s): +def collapse_whitespace(text): ''' Replace all whitespace sequences with a single space and strip the ends. ''' - s = re.sub(r'\s+', ' ', s.strip()) - return s + text = re.sub(r'\s+', ' ', text.strip()) + return text -def comma_space_split(s): +def comma_space_split(text): ''' Split the string by commas and spaces, discarding all extra whitespace and blank parts. 'a b, c,,d' -> ['a', 'b', 'c', 'd'] ''' - if s is None: - return s - return re.split(r'[ ,]+', s.strip()) + if text is None: + return text + return re.split(r'[ ,]+', text.strip()) def pascal_to_loudsnakes(text): '''