DRY up regex-based filter creation
Remove awful ternary, replace with similarly awful conditional