I have a variable that contains a list of items, separated with comma and I am trying to run on all values and if last latter equals the latter p - Store all of these values in a different custom field.
was using "endsWith" function but didn't return anything, and was my latest try was the below:
{{#Variablen.split(",")}} {{#if(trim(.).matches(".*p$"))}} {{trim(.)}}{{^last}}, {{/last}} {{/}} {{/}}
Any suggestions?
The example you show splits the variable on commas, and then tries to perform a trim() on the implied / unnamed, list item {{.}} followed by the inline iteration match() function in order to filter the list.
Although some functions can use {{.}} during long-format iteration, most cannot, as you are observing. And, the {{^last}}, {{/}} would apply to the entire iteration, not to just the conditional filtering...thus, potentially leaving a trailing comma-space at the end.
As an alternative, you can solve this scenario completely with inline iteration with a trim prior to the attempted match, with a small change to your regex. Then, add an explicit join for the delimiter.
{{Variablen.split(",").trim.match("^(.*p)$").join(", ")}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.