This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

How to use regex to filter result before publishing in a Mistral workflow?

On publish or publish-on-error in Mistral workflow, YAQL or Jinja expressions can be used. There is a regex_match, regex_replace, regex_search, and regex_substring custom functions/filters that StackStorm include. The following is an example in YAQL using regex_match. More examples can be found at st2/contrib/examples/actions/workflows/tests at master · StackStorm/st2 · GitHub.

version: '2.0'

examples.mistral-test-func-regex-match:
    description: A workflow for testing regex_match custom filter in mistral
    type: direct
    input:
        - input_str
        - regex_pattern
    output:
        result_jinja: <% $.result_jinja %>
        result_yaql: <% $.result_yaql %>
    tasks:

        task1:
            action: std.noop
            publish:
                result_jinja: '{{ regex_match(_.input_str, _.regex_pattern) }}'
                result_yaql: '<% regex_match($.input_str, $.regex_pattern) %>'