For example, I have a string:
The struct-of-application and struct-of-world
With re.sub
re.sub
Try this:
>>> p = re.compile(r"((\w+-)+\w+)") >>> p.sub('[\\1](http://\\1)','The struct-of-application and struct-of-world') 'The [struct-of-application](http://struct-of-application) and [struct-of-world](http://struct-of-world)'