'Set a sheet title, ensuring it is valid.'

def _set_title(self, value):

    bad_title_char_re = re.compile('[\\\\*?:/\\[\\]]')
    if bad_title_char_re.search(value):
        msg = 'Invalid    character    found    in    sheet    title'
        raise SheetTitleException(msg)
    if self._parent.get_sheet_by_name(value):
        i = 1
        while self._parent.get_sheet_by_name(('%s%d' % (value, i))):
            i += 1
        value = ('%s%d' % (value, i))
    if (len(value) > 31):
        msg = 'Maximum    31    characters    allowed    in    sheet    title'
        raise SheetTitleException(msg)
    self._title = value
