Reputation: 2133
v=vi nod-u
i want to split this string to obtain
l=[vi],[nod],[u]
l.split(" ") splits on the basis of space.
And i dont know the usage of the regular expression import functions properly. Could anyone explain how to do that?
Upvotes: 0
Views: 1778
Reputation: 1522
Are you trying to split the string to get words? If so, try the following:
>>> import re
>>> pattern = re.compile(r'\W+')
>>> pattern.split('vi nod-u')
['vi', 'nod', 'u']
Upvotes: 2