Methods for Working with the Register

Filter

The filter command is designed to further filter the contents of the register using regular expressions. It works in the same manner as the filter parameter of the parse command. The command is available only in the block context, because it manipulates the contents of the register.

Below are examples of using filter in the code:

          - find:
    path: a.somepath
    do:
    # PARSE TEXT CONTENT OF CURRENT BLOCK
    - parse

    # REGISTER VALUE: " The link is absent   "
    # LETS FILTER VALUE OF THE REGISTER
    - filter:
        args: \s+([a-z]{4})\s+

    # REGISTER VALUE: link
          

If you need to specify multiple regular expressions, you can do it this way:

          - filter:
    args:
        - \s+(\d+)\s*
        - \s+([a-z]{4})\s+
          

In this case, the templates will be processed until the first match.

We have already mentioned the process of normalization, next we will tell you how you can use it to clear and normalize the collected data.