[ python-Bugs-1104608 ] Wrong expression with \w+?

SourceForge.net noreply at sourceforge.net
Tue Jan 18 17:49:03 CET 2005


Bugs item #1104608, was opened at 2005-01-18 17:49
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1104608&group_id=5470

Category: Regular Expressions
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: rengel (engel_re)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: Wrong expression with \w+?

Initial Comment:
str = 'match the url www.junit.org with following regex'
regex = re.compile('(www\.\w+?\.\w+?)')
print regex.sub('<span class="url">\1</span>', str)
# It produces
match the url <span class="url">www.junit.o</span>rg
with following regex
# It should produce
match the url <span class="url">www.junit.org</span>
with following regex



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

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


More information about the Python-bugs-list mailing list