How to use Spotless Data?

Regex Rules

A regex, or a regular expression, is a small programming expression that can be used to check what is present in a text field.

Wikipedia has an excellent overview of regular expressions here:

There is also a useful regex tester here:

Spotless fully implements the Python3 implemented regular expression using the syntax:

match = regex.match(word)
    if match:
        if != "":
            return None
        return None

This means that any regex that matches in Python can be deployed in Spotless.

Fields specific to regex rules

The custom fields for Spotless regex rules are as follows:

  • regex - the regular expression


Example regex rules


There are many example regex rules in the API and an example of a valid JSON for a regex rule is shown below:

    "id": "positive-integer-validator-regex-rule-c0e8e0ce-e6c4-11e5-9730-9a79f06e9478",
    "name": "Positive integer Validator",
    "is_private": false,
    "fallback_mode": "remove_record",
    "default_value": "",
    "regex": "^[0-9]*$"

Creating regex rules

Regex rules can be created using the browseable API or in code.

Example code to create a regex rule is as follows:

import requests


# create a regex rule to validate
response =
    headers={"Authorization": "Token " + token},
        "name": "my first spotless regex rule",
        "is_private": false,
        "fallback_mode": "remove_record",
        "default_value": "",
        "regex": "^[0-9]*$"

It's fine to create testing regex rules but please be aware that rules that are not used for 90 days will be deleted from the platform.