Anders Swanson
Anders Swanson

Reputation: 3961

how to use python regex functions in dbt-jinja?

this PR adds all the re module functions to dbt-jinja, but how to use it? I tried the below two, but to no avail.

{% set matcher = re.match('Doug', 'Timestamps Doug') %}
're' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".
{% set matcher = match('Doug', 'Timestamps Doug') %}
> 'match' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

Upvotes: 1

Views: 6273

Answers (1)

Anders Swanson
Anders Swanson

Reputation: 3961

as was pointed out in a comment in the PR, there is a doc page that details that to use the re module, you prefix it's usage with modules.

{% set matcher = modules.re.match('Doug', 'Timestamps Doug') %}

Upvotes: 4

Related Questions