>>> re.split('x|(y)', 'AxB') ['A', None, 'B'] >>> re.split('(y)|x', 'AxB') ['A', None, 'B']
-
-
Replying to @jackdied
>>> re.split('x|()', 'AxB') ['A', None, 'B'] >>> re.split('()|x', 'AxB') ['AxB']
3 replies 0 retweets 1 like
Replying to @jackdied
Python (and most regex engines) have "leftmost first" matching semantics. In an alternation, the first branch that matches wins.
3:35 AM - 16 Feb 2017
0 replies
0 retweets
1 like
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.