New submission from Alcolo Alcolo:
Why
re.findall('^|a', 'a') != ['', 'a'] ?
We have:
re.findall('^|a', ' a') == ['', 'a']
and
re.findall('$|a', ' a') == ['a', '']
Capturing '^' take the 1st character. It's look like a bug ...
--
components: Regular Expressions
messages: 250364
nosy
Alcolo Alcolo added the comment:
Naively, I thinked that ^ is be considered as a 0-length token (like $, \b,
\B), then after capturing it, we can read the next token : 'a' (for the input
string "a").
I use a simple work around: prepending my string with ' ' (because ' ' is
neutr