Comparison functions - misonou/waterpipe GitHub Wiki

equals(==), notequals(!=)

Checks if the piped value is equal, or not equal, to the supplied argument. The comparison is done by its string representation.

{{foo}}  bar
{{foo == bar}}  true
{{foo != baz}}  true

more(>), less(<), ormore(>=), orless(<=), between

Checks if the piped value is more than, less than, more than or equal to, less than or equal to, or between the supplied argument(s).

Note: In constrast to the native comparison operator, undefined and null are always less than any other values; and arrays are compared element by element recursively.

{{foo}}  [1,3,5]
{{bar}}  [1,3]
{{baz}}  [2,4]

{{foo.0 < 3}}  true
{{foo.0 between 0 2}}  true
{{foo > bar}}  true
{{foo > baz}}  false

contains(*=), like

Checks if the string contains a substring or matches the given pattern.

Note: Any escape character (\) in regular expression needs to be escaped itself. For example a valid regular expression /\w/g needs to be written as /\\w/g.

{{"foobar" contains foo}}  true
{{"foobar" like /^foo/i}}  true

startswith(^=), endswith($=)

Checks if the string starts or ends with the given substring.

{{"foobar" ^= foo}}  true
{{"foobar" $= bar}}  true

iequals(~=), inotequals(!~=)

Checks if the string is equal, or not equal, to the given string by case-insensitive comparison.

{{"foobar" ~= Foobar}}  true
{{"foobar" !~= Foobar}}  false
⚠️ **GitHub.com Fallback** ⚠️