I'm currently studying regular expressions and have come across an inquiry.
So the title of the question is what I'm trying to find out. I thought since \s
represents a white space, re.split(" ", string)
and re.split("\s+", string)
would give out same values, as shown next:
>>> import re
>>> a = re.split(" ", "Why is this wrong")
>>> a
["Why", "is", "this", "wrong"]
>>> import re
>>> a = re.split("\s+", "Why is this wrong")
>>> a
["Why", "is", "this", "wrong"]
These two give out the same answers so I thought that they were the same thing. However, it turns out that these are different. In what case would it be different? And what am I missing here that is blinding me?