Bugs item #1104608, was opened at 2005-01-18 17:49 Message generated for change (Comment added) made by effbot 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: Deleted >Resolution: Wont Fix 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 ---------------------------------------------------------------------- >Comment By: Fredrik Lundh (effbot) Date: 2005-01-18 18:23 Message: Logged In: YES user_id=38376 No, it shouldn't. "+?" means the shortest possible match that's one character or more. If you want the longest possible match, get rid of the "?". (in this case, I'd use "(www[.\w]*)") </F> ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1104608&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com