Just AND your values with the values you want to keep, anything that's ANDed with a zero will be dropped off.
I'm not familiar with your specific syntax but this approach should work and the masking does it all in one operation as long as you combined all your values into one mask.