'Returns a regex pattern for matching against a mido.Message string.'

def __str__(self):

    if (self._msg is not None):
        regex_pattern = (('^' + mido.messages.format_as_string(self._msg, include_time=False)) + '    time=\\d+.\\d+$')
    else:
        parts = [('.*' if (self._type is None) else self._type)]
        for name in mido.messages.SPEC_BY_TYPE[self._inferred_types[0]]['value_names']:
            if (name in self._kwargs):
                parts.append(('%s=%d' % (name, self._kwargs[name])))
            else:
                parts.append(('%s=\\d+' % name))
        regex_pattern = (('^' + '    '.join(parts)) + '    time=\\d+.\\d+$')
    return regex_pattern
