code: def find_matches(text, collection, start_only=False, fuzzy=True, casing=None):
          last = last_word(text, include='most_punctuations')
          text = last.lower()
          completions = []
          if fuzzy:
              regex = '.*?'.join(map(escape, text))
              pat = compile('(%s)' % regex)
              for item in sorted(collection):
                  r = pat.search(item.lower())
                  if r:
                      completions.append((len(r.group()), r.start(), item))
          else:
              match_end_limit = len(text) if start_only else None
              for item in sorted(collection):
                  match_point = item.lower().find(text, 0, match_end_limit)
                  if match_point >= 0:
                      completions.append((len(text), match_point, item))
          if casing == 'auto':
              casing = 'lower' if last and last[-1].islower() else 'upper'
          def apply_case(kw):
              if casing == 'upper':
                  return kw.upper()
              return kw.lower()
          return (Completion(z if casing is None else apply_case(z), -len(text))
                  for x, y, z in sorted(completions))