随笔-341  评论-2670  文章-0  trackbacks-0
输入:
  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) 阅读(1461) 评论(0)  编辑 收藏 引用 所属分类: 脚本技术

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理