import re def bold_partial(long_string, partial): replacer = re.compile(partial, re.IGNORECASE) new_long_string = replacer.sub('<b>' + partial + '</b>', long_string) print new_long_string bold_partial('My name is Roger the Shrubber. I arrange, design, and sell shrubberies.', 'roger the shrubber') Returns:
My name is roger the shrubber. I arrange, design, and sell shrubberies.
I'd like to return the original case:
My name is Roger the Shrubber. I arrange, design, and sell shrubberies.
Sorry, but I'm a total noob. Any help would be greatly appreciated.