I'm using Stash to set and retrieve a list based on channel entries. I want to filter the list by a 'column' of data defined by a pipe-delimited set of values.

I'm having trouble though getting the regex to work. So, for example I have the following data in my list:


I'm using the following regex:

{exp:stash:get_list name="paper" parse="inward" match="#^((.*2).*)$#" against="parents"}

But only two of the above are being returned in the list:


If I test this pattern on Regex Tester it returns all results as expected.

Any thoughts on why this might be happening or how better to achieve this (so returns all data with 2)? I've tried simpler regex patterns (eg #2# or #2+#) with no success.



1 Answer 1


Surrounding each of the values with a separator, including the start and end of the index makes matching simple and ensures you match a '2' and not '22' or '212' (for example). I tend to use @ or / rather than | so that I don't need to escape the pipe in the regex.


Now you can easily match a specific number with:

{exp:stash:get_list name="paper" match="#@2@#" against="parents"}

Or either of two numbers:

{exp:stash:get_list name="paper" match="#@2@|@4@#" against="parents"}

Or require two numbers:

{exp:stash:get_list name="paper" match="#^(?=.*@2@)(?=.*@4@)#" against="parents"}

More on filtering with a custom index column here: https://github.com/croxton/Stash/wiki/Filtering%20lists%20with%20match%20against

  • Thanks Mark. Sorry but I can't seem to get this to work. I've posted up some sample code at gist.github.com/cole007/0747814121ee89f14dd3 - any thoughts why this might not be working? Cheers, Cole Commented Nov 3, 2014 at 10:44
  • PS am using a custom function to generate the delimited variable am filtering against. Could this be affecting things? Commented Nov 3, 2014 at 11:51
  • Possibly. I commented on your gist: gist.github.com/cole007/0747814121ee89f14dd3 Commented Nov 3, 2014 at 14:27
  • Thanks Mark - it looks like the get list is matching against the requested values, eg MATCH #^.*(@9@).*$# AGAINST {exp:arjo_news:parents entry_id="167"}. Tried experimenting with different parse orders, etc to no avail. Commented Nov 3, 2014 at 14:42
  • had a good luck and figured out the problem, thanks. Looks like the parse depth needed specifying. Seems to be working now, thanks! Commented Nov 3, 2014 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.