Filtering: In or Out, Exclusive or Inclusive and Regular Expressions

My current preferred open source, self-hosted & simple RSS reader is Selfoss. I compared several of these types of RSS readers in a prior post and came to different conclusion, but I’ve been using Selfoss for at least a year now. My having switched to it may have coincided with improvements from the mobile reading side, which used to be… not good.

I have at least one aggregated feed in my lineup which pulls in feeds from multiple sources based on a common topic. But a lot of the posts are about things I care not at all about. I’ll give an example. I really like posts about programming and exploring concepts in certain computer languages, but I really don’t want to know anything about commercial products related to programming or professional conferences. How can I keep that stuff out of my reader? By using Selfoss’s filter feature, of course.

That’s too easy, right? No, it depends. If, like me, you hear “filter” and think of things that will be excluded from a collection, then we are brothers of a different mother. If instead you thought of keywords that would omit things not matching the keywords, then you must be related to the author of the filter functionality in Selfoss. So this is my dilemma. Thankfully, I learned something new about regular expressions today.

Replace the following Langs with your favorite language or language abbreviation. I tried using simple alternation when I thought that filtering meant the opposite of how Selfoss does it.

Filter field of an RSS source in Selfoss
That’s when I started getting only posts that I didn’t want to see in my feed. :-) So I did some searching and finally found what I was looking for. I changed the simple alternation into something that regex really isn’t made for.
/^((?!LangCon|OverseasLangCon|LangProduct|Vendor|AppCon|LangVendor).)*$/
This is a negative look-ahead assertion that can be followed by anything not contained in the assertion. I suppose that’s just how you do it in regex without handy tools like grep’s -v switch.