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]+" }as_bool
Section titled “as_bool”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.
Options
Section titled “Options”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 valueas_float
Section titled “as_float”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_floatas_int
Section titled “as_int”Casts the result of the preceding evaluators into an integer. It will cleanup commas, and other symbols in the value before parsing.
Options
Section titled “Options”radix: The radix between 2 and 32. Defaults to 10.
$ "#price"; text; as_int$ "#hexcode"; text; as_int radix=16Gets the value for provided attribute name. The preceding evaluators should return an Element.
$ ".a"; attr hrefGets 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 -1default
Section titled “default”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 200extract
Section titled “extract”Extracts the provided regular expression from the preceding evalautors.
regex: The regular expression. Can be a static string or expression.
Options
Section titled “Options”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 totrue.
$ "#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()"matches
Section titled “matches”Checks if the preceding evalutors match the provided regular expression.
regex: The regular expression to match against.
Options
Section titled “Options”caseSensitive: Whether or not for the matching to be case sensistive. Defaults totrue.
$ ".title"; matches "(Python|Javascript|C++|Rust)" caseSensitive=#falseStatic 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 0Logical not operator. The preceding evaluators are grouped as the operand.
$ "#is-active"; text; as_bool; notLogical 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 lengthreplace
Section titled “replace”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.
Options
Section titled “Options”all: Whether to replace all matches of pattern. Defaults tofalse.regex: Whether or not to treatpatternas a regular expression. Defaults tofalse.caseSensitive: Ifregexis true, whether or not for the pattern match to be case sensistive. Defaults totrue.
$ ".price"; replace "$" ""$ ".price"; replace "[^0-9.]" "" regex=#trueResets 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