Issue
Here's the simplest way to explain this. Here's what I'm using:
>>> re.split('\W', 'foo/bar spam\neggs')
['foo', 'bar', 'spam', 'eggs']
Here's what I want:
>>> someMethod('\W', 'foo/bar spam\neggs')
['foo', '/', 'bar', ' ', 'spam', '\n', 'eggs']
The reason is that I want to split a string into tokens, manipulate it, then put it back together again.
Solution
>>> re.split('(\W)', 'foo/bar spam\neggs')
['foo', '/', 'bar', ' ', 'spam', '\n', 'eggs']
Answered By - Commodore Jaeger
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.