Matchers

Filtering Against Data Using Audisto Scripting Language

Matchers work on data that was gathered using scopes. They take data and an argument and return either TRUE if the data matches the argument, FALSE if not.

Matchers may process different kinds of data:

  • Text: Text based matchers process data as text. Case insensitive data is matched in a case insensitive way. Case sensitive data is processed in a case sensitive way.
  • Number: Number based matchers require the data to be a number. They accept only integer numbers as arguments.
  • HTML: HTML based matchers expect an HTML document as input. They provide easy access to elements of the document, like tags, attributes, or text.

Note: It is allowed to process numbers and HTML as text. This is valid:

HTTP Status Starts With "3"

Text Related Matchers

The following text processing matchers are available:

  • Contains: Match is successful if the scope contains the desired string
  • Starts With: Match is successful if the scope starts with the desired string
  • Ends With: Match is successful if the scope ends with the desired string
  • Equals: Match is successful if the scope equals the desired string
  • Is Like: Match is successful if the scope equals a string using wildcards. See below for details
  • Matches Regex: Match is successful if the scope matches the given regular expression. We support Java style regular expressions

Each matcher can also be negated by the according negative matches:

  • Does Not Contain: Match is successful if the scope does not contain the desired string
  • Does Not Start With: Match is successful if the scope does not start with the desired string
  • Does Not End With: Match is successful if the scope does not end with the desired string
  • Does Not Equal: Match is successful if the scope does not equal the desired string
  • Is Not Like: Match is successful if the scope does not equal the desired wildcarded string
  • Does Not Match Regex: Match is successful if the scope does not match the given regular expression.

The Is Like matcher supports an asterix as wildcard character, that matches arbitrary many characters.

Path Is Like "/category/*/top-products.html"

Note that without a starting asterix, the given string must start with the pattern. If you use a trailing asterix, the match fits the whole string, else it would fit the shortest possible match. This is relevant when used with URL rewriting.

When defining a match - especially when using Starts With or Ends With - be sure what the scope contains. Also have in mind that regular expressions are powerful but may also be confusing. Don't hesitate to contact us, if you have any questions. We are always eager to help.

There are a lot of regular expression testers on the web, just search for "java regex tester". We particularly liked these:

  • AppSpot. Simple and clean, supports Java.
  • Regex Planet: Supports full fledged Java expressions
  • Regex101: While not supporting Java directly, it explains expressions and allows an estimation of costs

Contains, Ends With, and Starts With do not support wildcards! Use Is Like or regular expressions for that.

Number Related Matchers

The following number related matchers are available to compare the input to a given value:

  • Less Than
  • Less Than Or Equal
  • Greater Than
  • Greater Than Or Equal
  • Exists: Short for Greater Than 0
  • Does Not Exist: Short for Equals 0

To compare numbers for equality, use Equals or Does Not Equal.

Note: Passing text into number based matchers leads to an error.

HTML Related Matchers

The following HTML processing matchers are available:

  • Matches XPath: Match is successful if the given XPath has one or more results
  • Matches CSS Selector: Match is successful if the given CSS Selector has one or more results

Each matcher can also be negated by the according negative matches:

  • Does Not Match XPath: Match is successful if the scope does not match the given XPath.
  • Does Not Match CSS Selector: Match is successful if the scope does not match the given CSS Selector.

XPath

HTML Matches XPath "//head/meta[@name='description' and @content='My best ranking meta description']"

We support XPath 1.0 only. Wikipedia has a good overview.

There are some free XPath-Testers on the web, but they usually only support valid XML documents, not HTML. However, most modern browsers support XPath querying within their developer tools right away. In both Chrome and Firefox, you may for example inspect an element, right click, and choose "Copy XPath" to obtains this element's XPath.

CSS Selectors

HTML Matches CSS Selector "form#register input[name=username]:required"

We fully support CSS Selectors Level 3, but with some notable adaptions:

  • Pseudo-elements like ::before or ::after always match, but the deprecated notation :before and :after is not supported
  • Dynamic pseudo-classes like :visited or :hover always match
  • Target pseudo-class :target never matches anything
  • UI element pseudo-class :indeterminate never matches anything
  • Language pseudo-class :lang is defined as the element or one of its parents having a HTML lang attribute with matching value. xml:lang is not taken into consideration

Additionally, these parts of upcoming CSS Selectors Level 4 are already supported:

  • Input pseudo-classes :required and :optional