<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.filters.RegexFilter.html -->
# RegexFilter

**`class RegexFilter(config)`**

Bases: [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter)

The regex [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter) filters documents based on a supplied list of blacklist and whitelist
regexes

**Input** - all input fields needs to be of type [`str`](https://docs.python.org/3.11/library/stdtypes.html#str).

**Output** - (optional) the output field is filled with data of type [`str`](https://docs.python.org/3.11/library/stdtypes.html#str).

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – regex
- `blacklist_regexes` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``[``]`) – List of blacklist regexes to apply
- `fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)) – Fields to apply regexes
- `output_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``None`) – Field to record if regex matches
- `matching_label` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``'match'`) – Label given if regex matches
- `non_matching_label` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``'no_match'`) – Label given if regex does not match
- `whitelist_regexes` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``[``]`) – List of whitelist regexes to apply
- `rule_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``None`) – Field to record the rule which triggered
  the match (manly used in the context of proximity filters)
- `no_rule_matched_label` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``'NO_RULE_MATCHED'`) – Rule given if regex does not match
  (manly used in the context of proximity filters)
- `default_language` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``'en'`) – Default language if language_field is not
  present.
- `language_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``'language'`) – Document field that gives the language.

**Example**

```json
{
    "step": "filter",
    "type": "regex",
    "fields": ["body"],
    "mark_as_skipped": true,
    "whitelist_regexes": ["^.{20,}$"]
}
```

Attributes SummaryMethods SummaryAttributes Documentation

**`REG_FLAGS = 0`**

Methods Documentation

**`process_doc(doc)`**

Process a document

Parameters

`doc` ([`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)) – Document

Returns

Processed document

Return type

[Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)
