Python's way of splitting strings by multiple characters
- 2020-04-02 14:41:08
- OfStack
This example shows how python splits strings by multiple characters. Share with you for your reference. Specific analysis is as follows:
This python code splits the string using this regular expression, using \w as the separator, as long as it's not a letter and a number.
import re
DATA = "Hey, you - what are you doing here! welcome to jb51?"
print re.findall(r"[w']+", DATA)
The output is as follows
['Hey', 'you', 'what', 'are', 'you', 'doing', 'here', 'welcome', 'to', 'jb51'
]
I hope this article has helped you with your Python programming.