import re


def _is_likely_concatenated_filenames(string, exts):
    """Check whether a string is likely a concatenated filenames.
    This situation is usually caused by missing a comma between file names.
    For example, if the user writes:
        ```
        [
            'first.h',
            'second.h'  # NOTE: Missing the ending ","
            'third.h',
        ]
        ```
        'second.h' will be concatenated with 'third.h' to be 'first.hsecond.h'
    """
    # Convert exts to regex, e.g., ['h', 'hpp'] to "(h|hpp)"
    ext_pattern = '(%s)' % '|'.join(e.replace('+', r'\+') for e in exts)
    return re.search(r'\w+\.{ext}.+\.{ext}$'.format(ext=ext_pattern), string)