Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 使用正则表达式检查cron条目';05***/usr/bin/aide——检查和#x27;_Regex_Rspec_Serverspec_Inspec - Fatal编程技术网

Regex 使用正则表达式检查cron条目';05***/usr/bin/aide——检查和#x27;

Regex 使用正则表达式检查cron条目';05***/usr/bin/aide——检查和#x27;,regex,rspec,serverspec,inspec,Regex,Rspec,Serverspec,Inspec,如何使用正则表达式检查cron条目05***/usr/bin/aide--check?我想在Chef InSpec登记一下 its('content') { should match /<the regular expression>/ } its('content'){应该匹配//} 正则表达式可以是/05***\/usr\/bin\/aide--check/ describe cron do it { expect(subject).to have_entry '0 5 *

如何使用正则表达式检查cron条目
05***/usr/bin/aide--check
?我想在Chef InSpec登记一下

its('content') { should match /<the regular expression>/ }
its('content'){应该匹配//}

正则表达式可以是
/05***\/usr\/bin\/aide--check/

describe cron do
  it { expect(subject).to have_entry '0 5 * * * /usr/bin/aide --check' }
end
是在Serverspec中执行此操作的正确方法,它还将立即解决格式化问题

如果您真的想使用regexp(并且您的后续注释作为答案暗示您不想使用),那么您可以这样做:

its(:content) { is_expected.to match %r{0 5 \* \* \* /usr/bin/aide --check} }

是否可能重复并转义星号?