I use Python’s re module to replace a substring, such as:
>>> import re
>>> re.sub(r"a.*b","ab","acbacbacb")
'ab'
This matches .* with cbacbac, but I want it to match c three times, so that the output is ababab.
Could anybody tell me how to do it?
Regex by default is greedy. Use
.*?http://docs.python.org/library/re.html