[Python-bugs-list] [ python-Bugs-432570 ] overlapping groups ?

noreply@sourceforge.net noreply@sourceforge.net
Tue, 12 Jun 2001 15:35:42 -0700


Bugs item #432570, was updated on 2001-06-12 15:35
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=432570&group_id=5470

Category: Regular Expressions
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: overlapping groups ?

Initial Comment:
with perl:

$tag = '<abc xyz="def/ghi">';
$tag =~ /<(\/|\?)?(.*?)(\/|\?)?>/;
print "1=$1\n";
print "2=$2\n";
print "3=$3\n";

you get:

1=
2=abc xyz="def/ghi"
3=

with python
(ActivePython 2.1, build 210 ActiveState
based on Python 2.1 (#15, Apr 19 2001, 10:28:27)
[MSC 32 bit (Intel)] on win32):

import re
p = re.compile("<(/|\?)?(.*?)(/|\?)?>")
tag = '<abc xyz="def/ghi"><test>'
m = p.search(tag)
print '1='+str(m.group(1))
print '2='+str(m.group(2))
print '3='+str(m.group(3))

you get:

1=None
2=abc xyz="def/ghi"
3=abc xyz="def/

uups ...

cu, jk.



----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=432570&group_id=5470