I have a stash list of different plans that I need to break based on whether the word light is in the title or not.

So here is what I'd like:

  1. One list of plans whose title contains the word light. If it doesn't contain light then I don't want it.
  2. Complete opposite to above. List of plans without light in the title.

I believe this possible using the match and against params in stash but I can't work out what the regex would be.





Then later in the template


Not sure on the regex required for not Light. Would be as simple as match="{#!Light#]"?

  • UPDATE: Just updated the final code example to have the correct against="" parameter value.
    – since1976
    Jan 29, 2013 at 3:04
  • 1
    Nate's excellent answer below is what you need, but I'd just point out that you don't need the parse_tags="yes" or parse_vars="yes" when you get the list. Also, be sure to enclose your regex pattern with hashes, e.g. #(?m)^((?!\b(l|L)ight\b).)*$# Jan 29, 2013 at 19:49

2 Answers 2


Inverse Matching


You can see it in action here and take note of the info in the shot. Everything highlighted is being matched or in this case not matching Light:


If you need to match both lowercase and capital light then you'd change it to this. Everything highlighted is being matched or in this case not matching Light or light:


And you end up with:

Patterns RegExp


\bLight\b matches Light:

patterns regex

And finally \b(l|L)ight\b matches both light and Light:


Note: Notice how we aren't picking up Lighttt? That's because we are wrapping with \b which sets up our match boundaries. Remove the two \b if you don't need boundaries.

Update: as pointed out by Mark Croxton in a comment:

Also, be sure to enclose your regex pattern with hashes, e.g. #(?m)^((?!\b(l|L)ight\b).)*$#

I'm sure Mark can explain this in more detail but the basic gist of it is that Stash itself reads regex wrapped in the hashes. This is something that, to my understanding anyway, pertains to Stash only; versus everyday regex.

  • 1
    ^ What Nate said :) Jan 29, 2013 at 8:54
  • Patterns is great for testing that kind of stuff out ;o) Jan 29, 2013 at 10:06
  • Nate, you sir are a legend. Thank you so much. Will check out Patterns app too.
    – since1976
    Jan 29, 2013 at 20:27
  • Honestly Mark is the legend here! In fact if it wasn't for him and Stash I would have never tried learning regex. He encouraged me one day to give it a shot and funny thing is I found it kind of fun. Like trying to solve a puzzle. Patterns is a great tool to use if you are on Mac. I'm sure there are some for other platforms as well. I know there are quite a few free online version which can be had via a quick Google Search for "regex tester" etc.
    – Natetronn
    Jan 29, 2013 at 21:59

I'm no regex guru, far from it - more a regex googler

A quick Google suggests that using negative look arounds to do an inverse match.


Should work

Also when using match against, you might have to use the stash title not the original 'title'


Either way this should, hopefully, help you on your way :)

  • Sorry that was a bad copy paste operation on my part. I am actually trying to match against="plan_title" as suggested. Still it pulls out all items in the list.
    – since1976
    Jan 29, 2013 at 3:03

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.