Movatterモバイル変換


[0]ホーム

URL:


CFEngine documentation homepage

every

Suggest changes
Table of contents

Prototype:every(regex, list)

Return type:boolean

Description: Returns whether every element in the variablelist matchestheunanchoredregex.

This function can accept many types of data parameters.

Arguments:

  • regex : Regular expression to find, in the range.*

  • list : The name of the list variable to check, in the range[a-zA-Z0-9_$(){}\[\].:]+. It can be a data container or a regularlist.

Example:

code
bodycommoncontrol{bundlesequence=>{"test"};}bundleagenttest{classes:"every_dot_star"expression=>every(".*",test);"every_dot"expression=>every(".",test);"every_number"expression=>every("[0-9]",test);"every2_dot_star"expression=>every(".*",test2);"every2_dot"expression=>every(".",test2);"every2_number"expression=>every("[0-9]",test2);vars:"test"slist=>{1,2,3,"one","two","three","long string","four","fix","six","one","two","three",};"test2"data=>parsejson('[1,2,3,"one","two","three","long string","four","fix","six","one","two","three",]');reports:"The test list is$(test)";every_dot_star::"every() test passed: every element matches '.*'";!every_dot_star::"every() test failed: not every element matches '.*'";every_number::"every() test failed: every element matches '[0-9]'";!every_number::"every() test passed: not every element matches '[0-9]'";every_dot::"every() test failed: every element matches '.'";!every_dot::"every() test passed: not every element matches '.'";"The test2 list is$(test2)";every2_dot_star::"every() test2 passed: every element matches '.*'";!every2_dot_star::"every() test2 failed: not every element matches '.*'";every2_number::"every() test2 failed: every element matches '[0-9]'";!every2_number::"every() test2 passed: not every element matches '[0-9]'";every2_dot::"every() test2 failed: every element matches '.'";!every2_dot::"every() test2 passed: not every element matches '.'";}

Output:

code
R: The test list is 1R: The test list is 2R: The test list is 3R: The test list is oneR: The test list is twoR: The test list is threeR: The test list is long stringR: The test list is fourR: The test list is fixR: The test list is sixR: every() test passed: every element matches '.*'R: every() test passed: not every element matches '[0-9]'R: every() test passed: not every element matches '.'R: The test2 list is 1R: The test2 list is 2R: The test2 list is 3R: The test2 list is oneR: The test2 list is twoR: The test2 list is threeR: The test2 list is long stringR: The test2 list is fourR: The test2 list is fixR: The test2 list is sixR: every() test2 passed: every element matches '.*'R: every() test2 passed: not every element matches '[0-9]'R: every() test2 passed: not every element matches '.'

History: Thecollecting function behavior was added in 3.9.

See also:About collecting functions,filter(),some(), andnone().

Still need help?

Chat Ask a question on Github Mailing list
Version 
master3.24 (LTS)3.21 (LTS)view all versions

[8]ページ先頭

©2009-2025 Movatter.jp