(defun match (pattern string)
  (let ((i 0)
        (len (length string))
        star)
    (loop
       for c across pattern
       while (< i len)
       do
         (case c
           (#\* (setf star t))
           (#\? (incf i))
           (otherwise (if star
                          (loop while (and (< i len) (not (eql c (elt string i))))
                             do (incf i)
                             finally (incf i) (setf star nil))
                          (if (eql c (elt string i))
                              (incf i)
                              (return))))))
     (and (= i len) (>= len (length pattern)))))


(princ (match "as*d*?qwe*qwe" "as123dssqwe12345678qwe"))
