我正在尝试匹配具有
"/foldera/folderb/folderc/folderd/file.ext@@/main" + "/" + ANY_NUMBER:
例如:
(.+)(main)(.\d)
这些行:
/foldera/folderb/folderc/folderd/file.ext@@/main
/foldera/folderb/folderc/folderd/file.ext@@/main/0
/foldera/folderb/folderc/folderd/file.ext@@/main/1
/foldera/folderb/folderc/folderd/file.ext@@/main/2
/foldera/folderb/folderc/folderd/file.ext@@/main/3
/foldera/folderb/folderc/folderd/file.ext@@/main/4
/foldera/folderb/folderc/folderd/file.ext@@/main/5 (RLT-abcde, BLD-abcde, DEV-abcde)
/foldera/folderb/folderc/folderx/file12.ext@@/main/0
/foldera/folderb/folderc/folderx/file12.ext@@/main/1
/foldera/folderb/folderc/folderx/file12.ext@@/main/2
/foldera/folderb/folderc/folderx/file12.ext@@/main/3
/foldera/folderb/folderc/folderx/file12.ext@@/main/4
/foldera/folderb/folderc/folderx/file12.ext@@/main/5
/foldera/folderb/folderc/folderx/file12.ext@@/main/6 (RLS-abcde-5.0, RLS-abcde-4.1)
虽然我的正则表达式匹配所需的行(我在http://www.regexe.com/检查它),但在我的 Perl 程序中它不匹配
/foldera/folderb/folderc/folderd/file.ext@@/main
但它确实匹配:
/foldera/folderb/folderc/folderd/file.ext@@/main/5 (RLT-abcde, BLD-abcde, DEV-abcde)
这是代码:
use warnings;
use strict;
my @file_list = `find /folder -type f -name '*.ext'|xargs cleartool lsvtree -all`;
foreach my $file(@file_list){
if ($file=~m/(.+)(main)(.\d)/g){
print $file;
}
}
我很确定我在某个地方犯了一个愚蠢的错误,但我就是看不到它!
预先感谢您的建议。
PS 我在 Perl 5.8 和 Perl 5.18 下尝试过,结果相同,操作系统是 Solaris。