#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. # """Substitute based on patterns. """ #end_pymotw_header import re bold = re.compile(r'\*{2}(.*?)\*{2}', re.UNICODE) text = 'Make this **bold**. This **too**.' print 'Text:', text print 'Bold:', bold.sub(r'<b>\1</b>', text)