substr

DPU:

0.1

Purpose:

To filter for a sequence of characters that form a word or part of a word.

Type:

The contains operator takes a string argument.

It does not use tokenization. It makes an exact string match on its arguments.

Case:

Not case sensitive. Add the cs keyword to create a case-sensitive filter with substr.

Syntax:

substr string

Synonyms:

contains_substr

Examples:

  1. Filter for a post that includes the string "news". This stream:

    interaction.content substr "news"

    will match this target text:

    "Newspapers report that only one person won the $100m lottery on Tuesday."

    and:

    "The quarterback renews his contract this afternoon."
  2. Filter for a post that includes "gator". This filter:

    interaction.content substr "gator"

    matches any of these strings:

    "The man only just escaped from the 'gator."
    
    "The alligator slept on the riverbank."
    
    "I always drink Gatorade when I cycle."
  3. Filter for a post that includes "News". This filter:

    interaction.content cs substr "News"

    matches this target text:

    "Newspapers report that only one person won the lottery on Tuesday."

    but will not match this target text:

    "The quarterback renews his contract for next year."

Notes:

  1. The substr operator performs a loose match. There is no edge detection so if the sequence of characters occurs anywhere in the raw interaction (including inside a URL) it will match. This stream:

    interaction.raw_content substr "101"

    will match this target text:

    "Take a look at this pic!!! bit.ly/AP101"
  2. You can use the substr operator across words. This stream:

    interaction.contents substr "en en"

    will match this target text:

    "Ten entry points."

    If there are three spaces between "Ten" and "entry", the filter must include three spaces:

    interaction.contents substr "en en"