...
Script | Squirro Item | Result | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
String Functions
contains(str, substring[, substrings…])
Returns true if the string contains any of the given substrings. Examples:
Code Block | ||
---|---|---|
| ||
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.
Directive | Meaning | Example |
---|---|---|
%a | Weekday as locale’s abbreviated name. | Sun, Mon, …, Sat (en_US); So, Mo, …, Sa (de_DE) |
%A | Weekday as locale’s full name. | |
%d | Day of the month as a zero-padded decimal number. | 01, 02, …, 31 |
%b | Month as locale’s abbreviated name. | Jan, Feb, …, Dec |
%B | Month as locale’s full name. | January, February, …, December |
%m | Month as a zero-padded decimal number. | 01, 02, …, 12 |
%Y | Year with century as a decimal number. | 1970, 1988, 2001, 2013 |
%H | Hour (24-hour clock) as a zero-padded decimal number. | 00, 01, …, 23 |
%I | Hour (12-hour clock) as a zero-padded decimal number. | 01, 02, …, 12 |
%p | Either AM or PM. | AM, PM |
%M | Minute as a zero-padded decimal number. | 00, 01, …, 59 |
%S | Second 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.
...