fork(2) download
  1. (defun match (pattern string)
  2. (let ((i 0)
  3. (len (length string))
  4. star)
  5. (loop
  6. for c across pattern
  7. while (< i len)
  8. do
  9. (case c
  10. (#\* (setf star t))
  11. (#\? (incf i))
  12. (otherwise (if star
  13. (loop while (and (< i len) (not (eql c (elt string i))))
  14. do (incf i)
  15. finally (incf i) (setf star nil))
  16. (if (eql c (elt string i))
  17. (incf i)
  18. (return))))))
  19. (and (= i len) (>= len (length pattern)))))
  20.  
  21.  
  22. (princ (match "as*d*?qwe*qwe" "as123dssqwe12345678qwe"))
  23.  
Success #stdin #stdout 0s 10480KB
stdin
Standard input is empty
stdout
T