新手问题 /^\./ , /^CVS$/ ,/^RCS$/

ifenx · 2013年03月04日 · 最后由 tumayun 回复于 2013年03月04日 · 1731 次阅读

require 'find'

IGNORES = [ /^./ , /^CVS$/ ,/^RCS$/ ]

def listdir(top) Find.find(top){ |path| if FileTest.directory?(path) dir, base = File.split(path) IGNORES.each{|re| if re =~ base Find.prune end } puts path end

} end

listdir(ARGV[0])

上面程序中 /^./ , /^CVS$/ ,/^RCS$/ 分别表示什么 麻烦解释下

去看一下正则表达式吧

以。开头的文件,CVS,RCS

@AlphaLiu 以点吗?应该是 Any single character 开头

@AlphaLiu /^\./ 是以。开头的文件,/^./才是 Any single character 开头吧。

@AlphaLiu 哈哈 so sorry! 我看的是帖子内容

需要 登录 后方可回复, 如果你还没有账号请 注册新账号