471,595 Members | 1,672 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

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 771

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 XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.