输入:
pattern : 含有通配符*与?的字符串
string : 被匹配的字符串
输出:true与false代表匹配成功与失败
1 func match :: (list char) -> (list char) -> bool
2 def match pattern string =
3 select pattern of
4 case empty :
5 select string of
6 case empty : true
7 else : false
8 end
9 case list charp tailp :
10 select string of
11 case empty : and (equ charp '*') (match tailp empty)
12 case list chars tails :
13 select charp of
14 case '?' : match tailp tails
15 case '*' : or (match tailp tails) (match pattern tails)
16 else : and (equ charp chars) (match tailp tails)
17 end
18 end
19 end
posted on 2008-10-01 09:41
陈梓瀚(vczh) 阅读(1470)
评论(0) 编辑 收藏 引用 所属分类:
脚本技术