Generates and returns compound regular expression

def get_regex(self):
        ''' Generates and returns compound regular expression '''
        regex = ''
        for flag in self.compound:
            if flag == '?' or flag == '*':
                regex += flag
            else:
                regex += '(' + '|'.join(self.flags[flag]) + ')'

        return regex