469,286 Members | 2,547 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Unexpected regex result

I'm working on the sources for the regex module (_sre.c) but I've come
across some behaviour that I wasn't aware of before:
>>re.match('((a)|b)*', 'abc').groups()
('b', 'a')

The regex module was modified to return this instead of the previous
('b', '') in issue #725106 because both Perl and sed returned this.

My version of the module returns ('b', None), which was what I thought/
expected was the correct answer. Could someone explain to me what the
rationale for returning ('b', 'a') is? Is it just because Perl and sed
do this? (And if so, why has it been decided that it shouldn't be
possible to split a string on a zero-width match even though Perl
does? :-()
Aug 22 '08 #1
0 727

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alan Pretre | last post: by
17 posts views Thread by clintonG | last post: by
5 posts views Thread by Dave | last post: by
reply views Thread by Karch | last post: by
1 post views Thread by Karch | last post: by
13 posts views Thread by bintom | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.