How would I do the equivalent of str.strip()
using regex?
So far I have:
>>> s = ' Luca Bercovici (characters) '
>>> re.sub('^\s|\s$','',s)
'Luca Bercovici (characters) '
This seems to remove all leading whitespace, but not trailing whitespace.
This looks ok: re.sub('^\s+|\s+$','',s)