Python 3
import re
P = re.compile(r'[\s\t]+')
re.sub(P, ' ', '\xa0 haha')
' haha'
Python 2
import re
P = re.compile(r'[\s\t]+')
re.sub(P, u' ', u'\xa0 haha')
u'\xa0 haha'
I desire the Python 3 behavior, but in Python 2 code. How come the regex pattern fails to match space-like codepoints like \xa0 in Python 2 but correctly matches these in Python 3?