Ported @romseygeek's removeMatching.

Not only did I give bad advice on #377, but I also moved the tests around underneath it, which makes it unmergeable. So instead of making him rebase it, I'm doing it myself.

Closes #377.