Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ScriptSquirro ItemResult


Code Block
attendee_count = count(attendees)
attendee_len = len(attendees)



Code Block
languagejs
{
  "title": "Example",
  "keywords": {
    "attendees": ["Jon", "Abigail", "Mark", "Rose ", "Isabella"]
  }
}



Code Block
languagejs
{
  "title": "Example",
  "keywords": {
    "attendees": ["Jon", "Abigail", "Mark", "Rose ", "Isabella"],
    "attendees_count": [5],
    "attendees_len": [3, 7, 4, 4, 8]
  }
}


String Functions

contains(str, substring[, substrings…])

Returns true if the string contains any of the given substrings. Examples:

Code Block
languagepy
if contains(campaign, 'Contact Us'):
    contains = 1
elif contains($body, 'contact', 'form'):
    contains = 1

endswith(str, substring)

Returns true if the string ends with the given substring.

find(regexp[, field…])

Returns matches of the given regular expression in the input item and return any matching groups.

join(separator, list)

Combines all elements of the list, separating them with the given separator.

len(str)

Return the size of a string.

...

Returns a lower-cased version of the string.

replace(regexp, replace, str)

Replace all occurrences of the given regular expression.

Example:

Code Block
# This example redacts email-like strings
$body = replace('\S+@\S+', 'REDACTED_EMAIL', $body)


sha1(str)

Return the SHA1 hash of the string.

...

Return the SHA512 hash of the string.

startswith(str, substring)

Returns true if the string starts with the given substring.

strip(str)

Return a copy of the string with all whitespace removed at the beginning and end of the string.

...

Return the difference between the two given datetime objects. The unit can be specified as "seconds", "minutes", "hours", "days" or "weeks". Short versions of these units can be used, such as "s" for seconds.

now([format_string])

Return the current date time in UTC time zone. If a format string is given, this is returned as a string with the formatting applied, otherwise it's returned as a datetime object.

strftime(date[, format_string])

Return a string formatted version of the given datetime object. The default format is %Y-%m-%dT%H:%M:%S.

to_datetime(value)

Converts the given value to a datetime. This only works if the string uses the Squirro datetime format (YYYY%Y-MM%m-DDTHH%dT%H:mm:ss).%M:%S).

Datetime format strings

Some date functions take format strings. This table lists the most commonly used format directives. See also the Python documentation for datetime format strings for a more complete reference.

DirectiveMeaningExample
%aWeekday as locale’s abbreviated name.
Sun, Mon, …, Sat (en_US);
So, Mo, …, Sa (de_DE)
%AWeekday as locale’s full name.
%dDay of the month as a zero-padded decimal number.01, 02, …, 31
%bMonth as locale’s abbreviated name.
Jan, Feb, …, Dec
%BMonth as locale’s full name.
January, February, …, December
%mMonth as a zero-padded decimal number.01, 02, …, 12
%YYear with century as a decimal number.1970, 1988, 2001, 2013
%HHour (24-hour clock) as a zero-padded decimal number.00, 01, …, 23
%IHour (12-hour clock) as a zero-padded decimal number.01, 02, …, 12
%pEither AM or PM.
AM, PM
%MMinute as a zero-padded decimal number.00, 01, …, 59
%SSecond as a zero-padded decimal number.00, 01, …, 59
%%A literal '%' character.%

Aggregation Functions

Aggregation functions are used on keywords and work on the entire list, instead of individual values. Most of the functions assume numeric values in the list.

...