Count

15 December 2023

  • C12 - added the regular expression option.

unknown C10 - initial

count (Sifts)
TypeCorrade progressive sift
Siftcount
Parametersa CSV string representing a regular expression (regex) and regular expression options
DescriptionThe count sift will count the number of items in a list that match a supplied regular expression.
Last ChangesNone

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

secondlife/scripted_agents/corrade/api/sifts/count.txt ยท Last modified: 2023/12/16 18:30 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.