访问被拒绝,你可能没有权限或未登录。

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

ifenx · March 04, 2013 · Last by tumayun replied at March 04, 2013 · 1732 hits

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! 我看的是帖子内容

You need to Sign in before reply, if you don't have an account, please Sign up first.