New submission from oliv <o_me...@yahoo.fr>:

Using python 2.6.4 on Arch Linux

The regular expression syntax in python indicate: 

(?(id/name)yes-pattern|no-pattern)
Will try to match with yes-pattern  if the group with given id or name exists, 
and with no-pattern  if it doesn’t.

I used that functionnality but the code doesn't works anymore:
import re
myre = 
re.compile('(?P<port>[0-9]+/(tcp|udp))\s+(?P<status>\S+)\s+(?P<service>[a-zA-Z0-9_-]+)\s*(?P<details>.*)')
myre.sub('(?(<details>)\g<details>|\g<service>)',"443/tcp open  ssl      
Microsoft IIS SSL")

> The output is:
'(?(<details>)Microsoft IIS SSL|ssl)'
Instead of:
Microsoft IIS SSL

It looks like a bug as it was working earlier...

----------
components: Build
messages: 100926
nosy: oliv
severity: normal
status: open
title: re.sub doesn't handle properly matches with yes-pattern no-pattern
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8122>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to