Regular Expression Filtering in Twitterrific (iOS)

What are regular expressions? Why should I use them?

Regular expressions (often abbreviated to regex) are sequences of characters that are often used in searching for patterns in words or phrases. They're a bit difficult to understand at first, but they're very powerful and can be useful for matching for terms that don't just show up in one way. Using them allows you to cover a variety of different permutations of a word or phrase without needing to create separate rules for each variation. To find out more about regular expressions check out the Wikipedia article on them, as well as this site about ICU regular expressions (which we use).

How do I add regular expression muffles and mutes to Twitterrific 5?

Regular expression (or regex) filtering in Twitterrific 5 is slightly different from other apps. These filters need a name that we can refer to them by, so we've come up with some simple syntax for creating them.

There are two parts to our regex filters: a name and the regex rule we filter by. We separate these from one another with two colons (or ::).

So say, for example, you want to mute spammers that offer you free iPhones on Twitter. When adding a new muffle filter in the muffle screen, you'd start with a name, let's say it's "Free iPhone". Then you'd create your rule. Something along the lines of:

want.*a.*free.*iPhone

To create a regex muffle in Twitterrific's muffle view, you'd write it out like this:

Free iPhone :: want.*a.*free.*iPhone

And bingo! Those spammers aren't bothering you anymore. Twitterrific uses ICU format regular expressions to filter tweets by looking at tweet's text body (shortened URLs and whatever you'd normally see in your timeline). Regular expressions have the potential to be very powerful, but they can also be somewhat confusing. To learn more about ICU regular expressions, go here: http://userguide.icu-project.org/strings/regexp.

How do I make my rule’s case-sensitive?

Twitterrific’s muffle rules are case-insensitive by default, but sometimes there are circumstances where the case of the characters matters. As of Twitterrific 5.14.4, you can create a case-sensitive regex pattern by using three colons instead of two (:::) when naming the rule. For example, the following will inadvertently match more tweets than intended, including tweets with the word “got” in them:

Game of Thrones Spoilers :: GoT

However the following rule, spelled with three colons instead of two, will only match tweets that have “GoT” in them with that exact capitalization:

Game of Thrones Spoilers ::: GoT

How complex can regular expression filtering get?

Regex filtering can get quite complex, and can expand to cover a wide variety situations. Say you wanted to filter all hashtags that involve a word or phrase followed by an emoji character. If you're using Twitterrific 5.10, you could write a regular expression like this: