Demo entry 5862518

123

   

Submitted by anonymous on Aug 09, 2016 at 03:25
Language: Python 3. Code size: 612 Bytes.

import re
collection = [ 'django_migrations.py',
               'django_admin_log.py',
               'main_generator.py',
               'migrations.py',
               'api_user.doc',
               'accounts.txt'
]

def LotusFinder(user_input, collection):
    suggection = []
    pattern = '.*?'.join(user_input)
    regex = re.compile(pattern)
    for item in collection:
        match = regex.search(item)
        if match:
            suggection.append((len(match.group()), match.start(), item))
    return [x for _, _, x in sorted(suggection)]
print(LotusFinder('mig', collection))
'''

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).