In Chapter 2, Section 2.1 of Python Cookbook 3rd Edition, you have the following:
>>> line = 'asdf fjdk; afed, fjek,asdf, foo'
>>> import re
>>> re.split(r'[;,\s]\s*', line)
['asdf', 'fjdk', 'afed', 'fjek', 'asdf', 'foo']
Yes it is a nice example... but when I try it out with removing the \s* in the regex it still has the same effect... see below:
>>> re.split(r'[;,\s]*', line)
['asdf', 'fjdk', 'afed', 'fjek', 'asdf', 'foo']
So, what does the author have in mind to make the redundant \s* useful for any other purposes than doing it without.. which is more simple and shorter?
Please make ur input.