我试图压制以[T 没有做正面匹配并否定结果的字符串.
my @tests = ("OT", "[T","NOT EXCLUDED");
foreach my $test (@tests)
{
#match from start of string,
#include 'Not left sq bracket' then include 'Not capital T'
if ($test =~ /^[^\[][^T]/) #equivalent to /^[^\x5B][^T]/
{
print $test,"\n";
}
}
Run Code Online (Sandbox Code Playgroud)
输出
NOT EXCLUDED
Run Code Online (Sandbox Code Playgroud)
我的问题是,有人可以告诉我为什么OT被排除在上面的例子中?
编辑 感谢您的答复到目前为止所有人,我可以看到我有点stoopid.