Replace extra whitespace inside of a string with a single space. Parameters ---------- s : str or unicode The string from which to remove extra whitespace. regex : re.Pattern The regular expression to use to remove extra whitespace. Returns -------
(s: str, regex: Pattern = _RE_WHITESPACE)
| 67 | |
| 68 | |
| 69 | def _remove_whitespace(s: str, regex: Pattern = _RE_WHITESPACE) -> str: |
| 70 | """ |
| 71 | Replace extra whitespace inside of a string with a single space. |
| 72 | |
| 73 | Parameters |
| 74 | ---------- |
| 75 | s : str or unicode |
| 76 | The string from which to remove extra whitespace. |
| 77 | regex : re.Pattern |
| 78 | The regular expression to use to remove extra whitespace. |
| 79 | |
| 80 | Returns |
| 81 | ------- |
| 82 | subd : str or unicode |
| 83 | `s` with all extra whitespace replaced with a single space. |
| 84 | """ |
| 85 | return regex.sub(" ", s.strip()) |
| 86 | |
| 87 | |
| 88 | def _get_skiprows(skiprows: int | Sequence[int] | slice | None) -> int | Sequence[int]: |