(defmacro case-it (keyform &body cases)
  `(let ((it ,keyform))
     (case it ,@cases)))

(defun match% (pattern string start end)
  (macrolet ((match%% (i)
               `(match% pattern string ,i end))
             (next-pattern ()
               `(or (pop pattern) (error "Pattern is incorrect"))))
    (cond ((null pattern) (= start end))
          ((= start end)  nil)
          (t
           (case-it (next-pattern)
             (#\? (match%% (1+ start)))
             (#\\ (and (eql (aref string start)
                            (next-pattern))
                       (match%% (1+ start))))
             (#\* (loop :for i :from start :to end
                        :for match-p := (match%% i) :until match-p
                        :finally (return match-p)))
             (t   (and (eql it (aref string start))
                       (match%% (1+ start)))))))))

(defun match (pattern string &key (start 0) (end (length string)))
  (match% (coerce pattern 'list) string start end))

(format t "~:[Not matched~;Matched~]" 
  (match "as*d*?qwe*qwe" "as123dssqwe12345678qwe"))