Table of Contents

Count

15 December 2023

  • C12 - added the regular expression option.

unknown C10 - initial

The count sift will count the number of items in a list that match a supplied regular expression.

Arguments

Name Type Description Example
pattern a string a regular expression [Ss]hoe
options a CSV of strings regular expression engine options IgnoreCase,Compiled

The full list of regular expression options that can be passed is documented on the Microsoft website.

Example

The following sift when added to a command will skip the first 2 items and then count the number of elements of the list that match the regular expression /[0-9]+?/:

    "sift", wasListToCSV([
        "skip", 2,
        "count",  wasURLEscape(
            wasKeyValueEncode(
                [
                    "pattern", "[0-9]",
                    "options", wasListToCSV([ "IgnoreCase", "Compiled" ])
                ]
            )
        )
    ]),

Effect on Returned Data

Given the input

data=a,1,c,2,e,3,h,4,h,5,j,7

the expected output is:

data=5