module Main where import Data.List (tails) type Pattern = String match :: Pattern -> String -> Bool match [] xs = null xs match _ [] = False match ('*':xs) str = any (match xs) $ tails str match ('?':xs) str = match xs $ tail str match ('\\':x:xs) (y:ys) = x == y && match xs ys match (x:xs) (y:ys) = x == y && match xs ys main = print $ match "as*d*?qwe*qwe" "as123dssqwe12345678qwe"