473,505 Members | 14,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 827

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2373
by: Alan Pretre | last post by:
Can anyone help me figure out a regex pattern for the following input example: xxx:a=b,c=d,yyy:e=f,zzz:www:g=h,i=j,l=m I would want four matches from this: 1. xxx a=b,c=d 2. yyy e=f 3....
4
9703
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
17
3941
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
5
2125
by: Dave | last post by:
#define BOOST_REGEX_DYN_LINK #include <iostream> #include <boost\regex.hpp> using namespace boost; using namespace std; int main() {
2
2808
by: GS | last post by:
How can one avoid capturing leading empty or blank lines? the data I deal with look like this "will be paid on the dates you specified. xyz supplier amount: $100.52 when: September 07,...
0
1724
by: Karch | last post by:
I have these two methods that are chewing up a ton of CPU time in my application. Does anyone have any suggestions on how to optimize them or rewrite them without Regex? The most time-consuming...
1
8775
by: Karch | last post by:
If you run this: string result = "<html><head></head><body>The body</body></html>"; result = retainBody.Replace(result, "$1"); With the following Regex: private static readonly Regex...
13
3573
by: bintom | last post by:
I ran the following simple code in C++ and got unexpected results: float f = 139.4; cout << f; Output: 139.399994;
1
1455
by: james2432 | last post by:
Parse error: syntax error, unexpected T_VARIABLE in /var/www/LukeSite/validateform.php on line 27 validateform.php <?php session_start(); if(empty($_SESSION)||!isset($_SESSION)){...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.