为什么这个正则表达式在 Puppet 中不匹配?

Why does this regular expression not match in Puppet?

目的是在 Puppet 中使用正则表达式匹配主机名 CI-TEST-POC。都不是:

if $hostname == /CI-(\[A-Z\]+)-POC/ {
  notice("Welcome to web server number ")
}

也不:

if $hostname =~ /CI-(\[A-Z\]+)-POC/ {
  notice("Welcome to web server number ")
}

匹配。为什么这个正则表达式在 Puppet 中不匹配?

好的,知道了。

if $hostname =~ /^CI-([A-Z]+)-POC$/ {
  notice("matches REGEXP XXX ")
} else { 
  notice("DIDN'T matches REGEXP XXX") 
}