Question about regular expression

Question about regular expression

Hi all,

I have a question about regexp in python, namely:
the string is like
  str =  "text [[link|name]] text2 [[link2|name2]] text3"

i want change  [[ and ]]to xxxx, and my re is:
  re.sub(r"\[\[(.*)\|(.*)\]\]", r"xxxx\1\|\2xxxx", str)

result is:
'text xxxxlink|name]] text2 [[link2\\|name2xxxx text3'

what i want is:
'text xxxxlink|namexxxx text2 xxxxlink2\\|name2xxxx text3'

what is the problem about my regexp?

Thank alot
I got it

* is a greedy match and non-greedy match should be used, namely here *? should be used instead of *

>>> re.sub(r"\[\[(.*?)\|(.*?)\]\]", r"xxxx\1\|\2xxxx", str)
'text xxxxlink\\|namexxxx text2 xxxxlink2\\|name2xxxx text3'