This is what I got.
Code:
from calibre.utils.icu import capitalize
from calibre.ebooks.oeb.polish.utils import apply_func_to_html_text
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
'''Capitalize matched text, ignoring the text inside tag definitions.'''
return apply_func_to_html_text(match, capitalize)