Created
August 26, 2019 15:22
-
-
Save CodersArts/cd5798e32be23354b3d90a8fb9da0091 to your computer and use it in GitHub Desktop.
split() regular expression in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
s = "HELLO there HOW are YOU" | |
l = re.compile("(?<!^)\s+(?=[A-Z])(?!.\s)").split(s) | |
print l | |
Output: | |
['HELLO there', 'HOW are', 'YOU'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment