Issue with validation function of a file extension

I created validation functions for some file extensions within to Plone add-ons. I got this validators working in one of the add-ons but they didn't work in the other one. The code of the validators (except its name and the variables in the catalog search) are the same. I call the validators within a constraint of a NamedBlobFile field (Dexterity content type).

def validateextfileextension(value):
catalog = api.portal.get_tool(name='portal_catalog')
result = catalog.uniqueValuesFor('allowedeupextensionfileextensions')
pattern = r'^.*.{0}'.format(result)
matches = re.compile(pattern, re.IGNORECASE).match
if not matches(value.filename):
raise Invalid(
u'You could only upload files with an allowed file '
u'extension. Please try again to upload a file with the '
u'correct file extension.')
return True

I set some print commands inside this code to compare the results of the different add-ons, but couldn't find any essential difference.
Here the results of my print commands:
print result: (u'oxt|OXT',)
print pattern: ^.*.(u'oxt|OXT',)
print (value.filename): LibreWeb-user-1.0.7.oxt
print (matches(value.filename)): None

The last print command leads to another result in the other add-on:
<_sre.SRE_Match object at 0x7f1d19b2ca08>

I looked through my code and couldn't find any essential difference. But maybe I'm a bit blind.
Here the code from the other add-on:

def validatetemplatefileextension(value):
catalog = api.portal.get_tool(name='portal_catalog')
result=catalog.uniqueValuesFor('allowedtuctemplatefileextensions')
pattern = r'^.*.{0}'.format(result)
matches = re.compile(pattern, re.IGNORECASE).match
if not matches(value.filename):
raise Invalid(
u'You could only upload files with an allowed template file '
u'extension. Please try again to upload a file with the '
u'correct template file extension.')
return True

Thanks for any hint in advance.

Please format your code properly

Sorry for the late answer, was outside with the family for hiking and site seeing whole day and a bit tired afterwards.

I had to apologize for the bad formatting of the code.

Here my code of the validator which doesn't work:


def validateextfileextension(value):
    catalog = api.portal.get_tool(name='portal_catalog')
    result = catalog.uniqueValuesFor('allowedeupextensionfileextensions')
    print result
    pattern = r'^.*\.{0}'.format(result)
    print (pattern)
    matches = re.compile(pattern, re.IGNORECASE).match
    print(value.filename)
    print (matches(value.filename))
    if not matches(value.filename):
        raise Invalid(
            u'You could only upload files with an allowed file '
            u'extension. Please try again to upload a file with the '
            u'correct file extension.')
    return True

And here is the code inside the other Plone add-on which works:

def validatetemplatefileextension(value):
    catalog = api.portal.get_tool(name='portal_catalog')
    result=catalog.uniqueValuesFor('allowedtuctemplatefileextensions')
    print result
    pattern = r'^.*\.{0}'.format(result)
    print(pattern)
    matches = re.compile(pattern, re.IGNORECASE).match
    print(value.filename)
    print(matches(value.filename))
    if not matches(value.filename):
        raise Invalid(
            u'You could only upload files with an allowed template file '
            u'extension. Please try again to upload a file with the '
            u'correct template file extension.')
    return True

The results of my print commands (in the validator, which doesn't work):

print result: (u'oxt|OXT',)
print pattern: ^.*.(u'oxt|OXT',)
print (value.filename): LibreWeb-user-1.0.7.oxt
print (matches(value.filename)): None

The only difference to the results of the other validator are the result of the last print command (for matches), which gave the result:
<_sre.SRE_Match object at 0x7f1d19b2ca08>

Thanks for any hints in advance.

I evaluated a bit more my validation functions and changed

pattern = r'^.*\.{0}'.format(result)

to

pattern = r'^.*\.{0}'.format(result[0])

The catalog search results in a Tuple and the value for the pattern was at its first place. Thus I picked this first entry in the Tuple.
But that didn't solved the issue. I played further with my development instance and found out that the issue disappeared once I edited the field in the parent object. This field was created with default values:

allowed_apdocfileextensions = schema.TextLine(
        title=_(u'Allowed Documentation File Extension'),
        description=_(u'Fill in the allowed documentation file extensions, '
                      u'seperated by a pipe \'|\'.'),
        default=_(u'odt|pdf'),
    )

In the case above the field was populated with 'odt|pdf'. Once I copied this entry, deleted the default entry of the field in the edit view and pasted it again in the field, everything works as expected.
This happens with Plone 5.0.10 on Python 2.7.9 and with Plone 5.2 on Python 3.6.