Question

Photo of Chris Bush

0

RegExMatchValue filter not working as expected

I have the following Lava executing in a template:

    {% assign message = "test-this 12345" %}
    {% assign test_result = message | RegExMatch:'\d+' %}
    {% assign matched_result = message | RegExMatchValue:'\d+' %}
    <!-- Regex id test: {{ test_result }} .. {{ matched_result }}-->


With the following output following evaluation:

    <!-- Regex id test: true .. test-this 12345-->

Am I using this filter incorrectly? According to the filter documentation i should expect the matched_result to be 12345, rather than the entire string.

Thanks

(this is Rock v8 btw)

  • Photo of Michael Allen

    0

    Hey Chris,

    RegExMatch was added back in Rock v5, but RegExMatchValue is a new filter coming in v9.

    If you need this functionality now, there is a plugin (https://www.rockrms.com/rockshop/plugin/65) that adds several useful lava filters, including a RegExMatchValue and a RegExReplace filter.