Skip to content

Evaluators

This page defines all of the built in evaluators.

$

Selects a single element using the provided selector.

  • selector: The CSS selector used to select an element. Can be a static string or expression.
$ ".element"

Logical and operator. All children nodes are treated as the right hand side of the operator and preceding evaluators as the left hand side.

$ ".element"; and { text; matches "[a-zA-Z]+" }

Casts the result of the preceding evaluators into a boolean. In addition to the falsy values in JavaScript, this also treats empty arrays as falsy and the strings provided in falsyValues as false.

  • falsyValues: Comma seperated string of values that are considered to be falsy. Defaults to "false,0,no".
$ "#element"; as_bool // whether or not element exists
$ ".passed"; as_bool falsyValues="negative" // custom falsy value

Casts the result of the preceding evaluators into a float. It will cleanup commas, and other symbols in the value before parsing.

$ "#price"; text; as_float

Casts the result of the preceding evaluators into an integer. It will cleanup commas, and other symbols in the value before parsing.

  • radix: The radix between 2 and 32. Defaults to 10.
$ "#price"; text; as_int
$ "#hexcode"; text; as_int radix=16

Gets the value for provided attribute name. The preceding evaluators should return an Element.

$ ".a"; attr href

Gets the child element at the provided index. Negative indexing is supported. The preceding evaluators should return an Element.

  • index: The index of the child. Negative indexing is supported.
// Get the first child
$ "a"; child 1
// Get the last child
$ "a"; child -1

Provides a default if the preceding evaluators return a falsy value.

  • value: The default value can be a static string, number or an expression.
$ "#get-element"; text; default "No Value"

Dynamic equality operator. All children nodes are treated as the right hand side of the operator and the preceding evaluators as the left hand side.

$ ".commenter"; text; deq { root; $ "#author"; text}

Dynamic inequality operator. All children nodes are treated as the right hand side of the operator and the preceding evaluators as the left hand side.

$ ".commenter"; text; dne { root; $ "#author"; text}

Static equality operator. The preceding evaluators are treated as the left hand side of the operator.

  • value: The value to compare to, can be a static string, number or an expression.
$ "#author"; eq "Zach Perkitny"
$ "#status_code"; eq 200

Extracts the provided regular expression from the preceding evalautors.

  • regex: The regular expression. Can be a static string or expression.
  • index: The capturing group index. Group indexing starts at 1, 0 returns the entire match. Defaults to 1.
  • caseSensitive: Whether or not for the extraction to be case sensistive. Defaults to true.
$ "#contact"; text; extract "Primary Phone: ([0-9]{3}\-[0-9]{3}\-[0-9]{4})"

Calls a custom JavaScript function. It is a useful fallback if there isn’t an existing evaluator shorthand for some desired functionality.

  • func: The function definition.
$ "#some-id"; func "(e) => e.hasAttributes()"

Checks if the preceding evalutors match the provided regular expression.

  • regex: The regular expression to match against.
  • caseSensitive: Whether or not for the matching to be case sensistive. Defaults to true.
$ ".title"; matches "(Python|Javascript|C++|Rust)" caseSensitive=#false

Static equality operator. The preceding evaluators are treated as the left hand side of the operator.

  • value: The value to compare to, can be a static string, number or an expression.
$ "#author"; ne "Zach Perkitny"
$ ".star_count"; ne 0

Logical not operator. The preceding evaluators are grouped as the operand.

$ "#is-active"; text; as_bool; not

Logical or operator. If the preceding evaluator is falsy, it executes and returns the result of the children nodes.

$ ".on-sale"; or { ".title"; matches "sale" caseSensitive=#false }

Access the provided property on the result of the preceding evaluators.

  • name: The name of the property to access.
$ "#posts-container"; prop children; prop length

Replaces the provided pattern (literal string or regex) with provided replacement string.

  • pattern: The pattern to match against. Can be a static string or expression.
  • replacement: The replacement value.
  • all: Whether to replace all matches of pattern. Defaults to false.
  • regex: Whether or not to treat pattern as a regular expression. Defaults to false.
  • caseSensitive: If regex is true, whether or not for the pattern match to be case sensistive. Defaults to true.
$ ".price"; replace "$" ""
$ ".price"; replace "[^0-9.]" "" regex=#true

Resets the evaluation context to the original value/element. This allows you to “branch” out and perform multiple independent checks on the same starting data.

$ ".sale-price"; or { root; $ ".price" }

Gets the inner text of the element.

$ "#bio"; text