re.sub and empty groups

2007-01-16 Thread Hugo Ferreira
Hi! I'm trying to do a search-replace in places where some groups are optional... Here's an example: re.match(rImage:([^\|]+)(?:\|(.*))?, Image:ola).groups() ('ola', None) re.match(rImage:([^\|]+)(?:\|(.*))?, Image:ola|).groups() ('ola', '') re.match(rImage:([^\|]+)(?:\|(.*))?,

Re: re.sub and empty groups

2007-01-16 Thread harvey . thomas
Hugo Ferreira wrote: Hi! I'm trying to do a search-replace in places where some groups are optional... Here's an example: re.match(rImage:([^\|]+)(?:\|(.*))?, Image:ola).groups() ('ola', None) re.match(rImage:([^\|]+)(?:\|(.*))?, Image:ola|).groups() ('ola', '')

Re: re.sub and empty groups

2007-01-16 Thread harvey . thomas
Hugo Ferreira wrote: Hi! I'm trying to do a search-replace in places where some groups are optional... Here's an example: re.match(rImage:([^\|]+)(?:\|(.*))?, Image:ola).groups() ('ola', None) re.match(rImage:([^\|]+)(?:\|(.*))?, Image:ola|).groups() ('ola', '')