Recently, I tried some code that is supposed to create an html link if a certain syntax is entered. However, the resulting behavior is far from the one expected:

Input:

```
string = u"[id: 196]"

```

Code 

```
reg = re.compile("(\[id:\s*(\d+)\])")
matches = re.findall(reg, string)
for match in matches:
    entry = object_pool.find(int(match[1])) // Just returns an object (already tested)
    string = re.sub(match[0], "<a href='/search#?id=%s?'>%s</a>" % (entry.id, entry.name), string)

```

I expect the following ouput:

```
<a href='/search#?id=196'>Production line n°4</a>

```

However, the actual output is [Production line n°4Production line n°4Production line n°4Production line n°4Production line n°4Production line n°4]

```
[<a href='/search#?id=196'>Production line n°4</a><a href='/search#?id=196'>Production line n°4</a><a href='/search#?id=196'>Production line n°4</a><a href='/search#?id=196'>Production line n°4</a><a href='/search#?id=196'>Production line n°4</a><a href='/search#?id=196'>Production line n°4</a>]

```

Is there something I didn't understand? Did I accidentally break the laws of programming and had the python eat its own tail in a loop of death? Do I deserve the death penalty? Any help would be appreciated.