Skip to content

Instantly share code, notes, and snippets.

@ryanblock
Created August 29, 2012 02:27

Revisions

  1. ryanblock revised this gist Sep 3, 2012. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -25,23 +25,23 @@ That one kind of broke down for me pretty quickly, though, so I tried mentions (

    I've found that wasn't very effective, though, because @ryan might be mentioned anywhere. Also, the {3,} has been crashing TweetBot for Mac. So I created this set of four expressions to nuke the appearance of @ryan in any tweet with any three other mentions:
    ```
    (?i:@ryan.*)(@\w+.*)(@\w+.*)(@\w+)
    (?s)(?i:@ryan.*)(@\w+.*)(@\w+.*)(@\w+)
    ```
    ```
    (@\w+.*)(?i:@ryan.*)(@\w+.*)(@\w+)
    (?s)(@\w+.*)(?i:@ryan.*)(@\w+.*)(@\w+)
    ```
    ```
    (@\w+.*)(@\w+.*)(?i:@ryan.*)(@\w+)
    (?s)(@\w+.*)(@\w+.*)(?i:@ryan.*)(@\w+)
    ```
    ```
    (@\w+.*)(@\w+.*)(@\w+.*)(?i:@ryan)
    (?s)(@\w+.*)(@\w+.*)(@\w+.*)(?i:@ryan)
    ```

    **Multi-RTs**

    The second worst offender: basically the same mention spam above, but a variant where these kids are using a lots of old school retweets instead all those first names. This regex kills anything with multiple `RT`s in a single post. [Updated to be much more greedy, watch out!]
    ```
    (RT).*?(RT)
    (?s)(RT).*?(RT)
    ```

    **Quotes immediately preceding the reply**
  2. ryanblock revised this gist Sep 2, 2012. 1 changed file with 20 additions and 18 deletions.
    38 changes: 20 additions & 18 deletions @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ The top #wrongryan offender is, believe it or not, teenage Twitter users in Mala

    First, the long, rambling list (with, or without commas):
    ```
    (@\w+,?){3,}@[Rr]yan
    (@\w+,?){3,}@ryan
    ```

    That one kind of broke down for me pretty quickly, though, so I tried mentions (at least 3) scattered all over the place:
    @@ -25,16 +25,16 @@ That one kind of broke down for me pretty quickly, though, so I tried mentions (

    I've found that wasn't very effective, though, because @ryan might be mentioned anywhere. Also, the {3,} has been crashing TweetBot for Mac. So I created this set of four expressions to nuke the appearance of @ryan in any tweet with any three other mentions:
    ```
    (@[Rr][Yy][Aa][Nn].*)(@\w+.*)(@\w+.*)(@\w+)
    (?i:@ryan.*)(@\w+.*)(@\w+.*)(@\w+)
    ```
    ```
    (@\w+.*)(@[Rr][Yy][Aa][Nn].*)(@\w+.*)(@\w+)
    (@\w+.*)(?i:@ryan.*)(@\w+.*)(@\w+)
    ```
    ```
    (@\w+.*)(@\w+.*)(@[Rr][Yy][Aa][Nn].*)(@\w+)
    (@\w+.*)(@\w+.*)(?i:@ryan.*)(@\w+)
    ```
    ```
    (@\w+.*)(@\w+.*)(@\w+.*)(@[Rr][Yy][Aa][Nn])
    (@\w+.*)(@\w+.*)(@\w+.*)(?i:@ryan)
    ```

    **Multi-RTs**
    @@ -48,66 +48,68 @@ The second worst offender: basically the same mention spam above, but a variant

    For some reason a LOT of erroneous tweets to me look something like `"@ryan` (note the preceding quotation). Don't ask me why. (Updated to prevent false positives on quote-style retweets.)
    ```
    ^.+[“"]@[Rr]yan
    ^.+[“"](?i:@ryan)
    ```

    **Empty replies**

    For tweets that only contain "@ryan" and nothing else. Sorry, [@Hodgman](https://twitter.com/hodgman/status/196878508650270720).
    ```
    ^@[Rr]yan$
    ^(?i:@ryan)$
    ```

    **All caps**

    An lot of wrongryans come in the form of all caps. As usual, don't ask me why. But I'm pretty sure I've never seen an intentional reply come in this way.
    ```
    @[R][Y][A][N]
    (@RYAN)
    ```

    **Truncated mentions of other Ryans**

    I see this one a lot specifically when retweets of TechCrunch articles by @RyanLawler get truncated. This version uses a single elipsis character or standard three periods (thanks @noahhendrix!).
    ```
    @[Rr]yan(…|\.{3,})$
    (?i:@ryan)(…|\.{3,})$
    ```

    **Trailing mentions**

    Again, chalk it up to "I don't get it", but a lot of wrongryans just feature a "@ryan" right at the end of the tweet for seemingly no good reason. But the problem with doing a simple expression like `@ryan$` is that sometimes people write real tweets with a trailing mention, like a hat tip, cc, via, etc. (i.e. "Blah blah blah /via @ryan"). So we need to prevent those crediting mentions from getting accidentally blocked. For that we'll use an inverse match:
    Again, chalk it up to "I don't get it", but a lot of wrongryans just feature a "@ryan" right at the end of the tweet for seemingly no good reason. But the problem with doing a simple expression like `@ryan$` is that sometimes people write real tweets with a trailing mention, like a hat tip, cc, via, etc. (i.e. "Blah blah blah /via @ryan").

    We can prevent those crediting mentions from getting accidentally blocked, though! For that we'll use a negative lookbehind:
    ```
    [^\/|^(CC:?|cc:?|HT:?|ht:?|via:?)] @[Rr]yan$
    (?i)(?<!cc|ht|via|/|:) @ryan$
    ```

    **Anti-Seacrest, Sheckler, Reynolds, etc.**

    Duh. Also, his name is occasionally typoed as "seacret". Okay.
    ```
    [Ss]eacre(s??)t
    (?i:seacres?t)
    ```

    Apparently the kids these days also try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler".
    Apparently the kids these days also try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler" or "shekler".
    ```
    [Ss]he(c?)(k?)ler
    (?i:shec?k?ler)
    ```

    And then there's Ryan "Renolds" (sigh).
    ```
    [Rr]e(y?)nolds
    (?i:rey?nolds)
    ```

    **Anti-Paul Ryan**

    Fun tip: left and right alike, people who wrongryan on Paul Ryan's name tend to be nut jobs. And most make the same mistake. I also pair this with any mentions of `@romney`, which really does it.
    Fun tip: left and right alike, people who wrongryan on Paul Ryan's name tend to be nut jobs. And most make the same mistake. I also pair this with any mentions of `@romney`, which really does it. This one is just a regular filter, though, not regex:
    ```
    Paul @[Rr]yan
    paul @ryan
    ```

    **Anti-Ryan Murphy**

    This guy does the Glee show, right? Gleeks aren't very excellent at Twittering.
    ```
    @[Rr]yan Murphy
    @ryan murphy
    ```

    **Anti-other Ryans**
  3. ryanblock revised this gist Sep 2, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,11 @@ As it turns out, most normal humans are incapable of learning to use Twitter @ r

    Then Tweetbot -- and its ability to use regex as Twitter filters -- came along. Here's how the Tapbots guys and some regular expressions single-handedly made my Twitter replies usable again.

    Note: 1) I'm not a regex expert. Far from it. I suck at regex, actually. If you have suggestions for improvements, please leave them below! 2) Some regex may look a little sloppy, but in actuality was written because TweetBot for Mac's regex filter support is very early, and things like repeats (`expression{3,}`) are buggy. So everything here should work without crashing Tweetbot for iPhone, iPad, and Mac.
    **Notes and caveats**

    * I'm not a regex expert. Far from it. I suck at regex, actually. If you have suggestions for improvements, please leave them below!
    * Some regex may look a little sloppy, but in actuality was written because TweetBot for Mac's regex filter support is very early, and things like repeats (`expression{3,}`) are buggy. So everything below should work without crashing Tweetbot for iPhone, iPad, and Mac.
    * Obvious, but not everyone should make use of every filter below. These filters are all tuned for reply spam on my particular account, and many of these filters may actually result in false positives. So be careful!

    **Lots and lots of user mentions**

  4. ryanblock revised this gist Sep 2, 2012. 1 changed file with 44 additions and 7 deletions.
    51 changes: 44 additions & 7 deletions @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -3,17 +3,36 @@ As it turns out, most normal humans are incapable of learning to use Twitter @ r

    Then Tweetbot -- and its ability to use regex as Twitter filters -- came along. Here's how the Tapbots guys and some regular expressions single-handedly made my Twitter replies usable again.

    Note: 1) I'm not a regex expert. Far from it. I suck at regex, actually. If you have suggestions for improvements, please leave them below! 2) Some regex may look a little sloppy, but in actuality was written because TweetBot for Mac's regex filter support is very early, and things like repeats (`expression{3,}`) are buggy. So everything here should work without crashing Tweetbot for iPhone, iPad, and Mac.

    **Lots and lots of user mentions**

    The top #wrongryan offender is, believe it or not, teenage Twitter users in Malaysia who blast out tweets with up to a dozen of their friends' first names. There's no pattern, and no awareness that the replies are all pointing to the wrong people. And as it happens, apparently Ryan is a popular first name. A couple of ways to do this. First, the long, rambling list:
    The top #wrongryan offender is, believe it or not, teenage Twitter users in Malaysia who blast out tweets with up to a dozen of their friends' first names. There's no pattern, and no awareness that the replies are all pointing to the wrong people. And as it happens, apparently Ryan is a popular first name. A couple of ways to do this.

    First, the long, rambling list (with, or without commas):
    ```
    (@\w+,?){3,}@[Rr]yan
    ```
    Second, mentions (at least 3) scattered all over the place:

    That one kind of broke down for me pretty quickly, though, so I tried mentions (at least 3) scattered all over the place:
    ```
    (@\w+.*){3,}(@ryan)
    ```

    I've found that wasn't very effective, though, because @ryan might be mentioned anywhere. Also, the {3,} has been crashing TweetBot for Mac. So I created this set of four expressions to nuke the appearance of @ryan in any tweet with any three other mentions:
    ```
    (@[Rr][Yy][Aa][Nn].*)(@\w+.*)(@\w+.*)(@\w+)
    ```
    ```
    (@\w+.*)(@[Rr][Yy][Aa][Nn].*)(@\w+.*)(@\w+)
    ```
    ```
    (@\w+.*)(@\w+.*)(@[Rr][Yy][Aa][Nn].*)(@\w+)
    ```
    ```
    (@\w+.*)(@\w+.*)(@\w+.*)(@[Rr][Yy][Aa][Nn])
    ```

    **Multi-RTs**

    The second worst offender: basically the same mention spam above, but a variant where these kids are using a lots of old school retweets instead all those first names. This regex kills anything with multiple `RT`s in a single post. [Updated to be much more greedy, watch out!]
    @@ -28,6 +47,13 @@ For some reason a LOT of erroneous tweets to me look something like `"@ryan` (no
    ^.+[“"]@[Rr]yan
    ```

    **Empty replies**

    For tweets that only contain "@ryan" and nothing else. Sorry, [@Hodgman](https://twitter.com/hodgman/status/196878508650270720).
    ```
    ^@[Rr]yan$
    ```

    **All caps**

    An lot of wrongryans come in the form of all caps. As usual, don't ask me why. But I'm pretty sure I've never seen an intentional reply come in this way.
    @@ -42,21 +68,30 @@ I see this one a lot specifically when retweets of TechCrunch articles by @RyanL
    @[Rr]yan(…|\.{3,})$
    ```

    **Trailing mentions**

    **Anti-Seacrest**
    Again, chalk it up to "I don't get it", but a lot of wrongryans just feature a "@ryan" right at the end of the tweet for seemingly no good reason. But the problem with doing a simple expression like `@ryan$` is that sometimes people write real tweets with a trailing mention, like a hat tip, cc, via, etc. (i.e. "Blah blah blah /via @ryan"). So we need to prevent those crediting mentions from getting accidentally blocked. For that we'll use an inverse match:
    ```
    [^\/|^(CC:?|cc:?|HT:?|ht:?|via:?)] @[Rr]yan$
    ```

    **Anti-Seacrest, Sheckler, Reynolds, etc.**

    Duh. Also, his name is occasionally typoed as "seacret". Okay.
    ```
    [Ss]eacre(s??)t
    ```

    **Anti-Sheckler**

    Apparently the kids these days often try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler".
    Apparently the kids these days also try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler".
    ```
    [Ss]he(c?)(k?)ler
    ```

    And then there's Ryan "Renolds" (sigh).
    ```
    [Rr]e(y?)nolds
    ```

    **Anti-Paul Ryan**

    Fun tip: left and right alike, people who wrongryan on Paul Ryan's name tend to be nut jobs. And most make the same mistake. I also pair this with any mentions of `@romney`, which really does it.
    @@ -79,6 +114,8 @@ Oh, there are so, so many. I've just completely filtered out anything including:
    * Boyce
    * Beatty
    * Higa (with preceding space, so as not to filter out words like "Michigan")
    * Giggs
    * The list goes on...

    ## Hat tip!
    The nerds in the audience can probably tell that I'm not very good at regex. So a big ass tip of the hat to Githubbers [Justin](http://github.com/justin) and [imathis](http://github.com/imathis) for their [awesome](https://github.com/justin/SilencedBots) [filters](https://gist.github.com/3006330).
    A big ass tip of the hat to Githubbers [Justin](http://github.com/justin) and [imathis](http://github.com/imathis) for their [awesome](https://github.com/justin/SilencedBots) [filters](https://gist.github.com/3006330), as well as [Logan Bailey](http://github.com/baileylo) for some input.
  5. ryanblock revised this gist Aug 31, 2012. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -5,10 +5,14 @@ Then Tweetbot -- and its ability to use regex as Twitter filters -- came along.

    **Lots and lots of user mentions**

    The top #wrongryan offender is, believe it or not, teenage Twitter users in Malaysia who blast out tweets with up to a dozen of their friends' first names. There's no pattern, and no awareness that the replies are all pointing to the wrong people. And as it happens, apparently Ryan is a popular first name.
    The top #wrongryan offender is, believe it or not, teenage Twitter users in Malaysia who blast out tweets with up to a dozen of their friends' first names. There's no pattern, and no awareness that the replies are all pointing to the wrong people. And as it happens, apparently Ryan is a popular first name. A couple of ways to do this. First, the long, rambling list:
    ```
    (@\w+,?){3,}@[Rr]yan
    ```
    Second, mentions (at least 3) scattered all over the place:
    ```
    (@\w+.*){3,}(@ryan)
    ```

    **Multi-RTs**

    @@ -19,9 +23,9 @@ The second worst offender: basically the same mention spam above, but a variant

    **Quotes immediately preceding the reply**

    For some reason a LOT of erroneous tweets to me look something like `"@ryan` (note the preceding quotation). Don't ask me why.
    For some reason a LOT of erroneous tweets to me look something like `"@ryan` (note the preceding quotation). Don't ask me why. (Updated to prevent false positives on quote-style retweets.)
    ```
    [“"]@[Rr]yan
    ^.+[“"]@[Rr]yan
    ```

    **All caps**
    @@ -43,14 +47,14 @@ I see this one a lot specifically when retweets of TechCrunch articles by @RyanL

    Duh. Also, his name is occasionally typoed as "seacret". Okay.
    ```
    [Ss]ecre(s??)t
    [Ss]eacre(s??)t
    ```

    **Anti-Sheckler**

    Apparently the kids these days often try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler".
    ```
    [Ss]hec(k??)ler
    [Ss]he(c?)(k?)ler
    ```

    **Anti-Paul Ryan**
  6. ryanblock revised this gist Aug 29, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -12,9 +12,9 @@ The top #wrongryan offender is, believe it or not, teenage Twitter users in Mala

    **Multi-RTs**

    The second worst offender: basically the same mention spam above, but a variant where these kids are using a lots of old school retweets instead all those first names. This regex kills anything with multiple `RT`s in a single post.
    The second worst offender: basically the same mention spam above, but a variant where these kids are using a lots of old school retweets instead all those first names. This regex kills anything with multiple `RT`s in a single post. [Updated to be much more greedy, watch out!]
    ```
    RT[^RT]+RT
    (RT).*?(RT)
    ```

    **Quotes immediately preceding the reply**
  7. ryanblock revised this gist Aug 29, 2012. 2 changed files with 2 additions and 88 deletions.
    10 changes: 2 additions & 8 deletions @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -33,17 +33,11 @@ An lot of wrongryans come in the form of all caps. As usual, don't ask me why. B

    **Truncated mentions of other Ryans**

    I see this one a lot specifically when retweets of TechCrunch articles by @RyanLawler get truncated. This version uses a single elipsis character.
    I see this one a lot specifically when retweets of TechCrunch articles by @RyanLawler get truncated. This version uses a single elipsis character or standard three periods (thanks @noahhendrix!).
    ```
    @[Rr]yan$
    @[Rr]yan(…|\.{3,})$
    ```

    **Truncated mentions of other Ryans**

    See above; this version uses three periods. Yes, I could probably combine the two, but I'm lazy and regex is hard for my tiny brain.
    ```
    @[Rr]yan...$
    ```

    **Anti-Seacrest**

    80 changes: 0 additions & 80 deletions ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -1,80 +0,0 @@
    ## How Tweetbot and regex made my Twitter replies usable again
    As it turns out, most normal humans are incapable of learning to use Twitter @ replies. And in case you don't follow me on Twitter: yes, my handle (@ryan) gets a lot of erroneous mentions. (The most amusing, random ones I've even taken to retweeting under the #wrongryan hashtag.)

    Then Tweetbot -- and its ability to use regex as Twitter filters -- came along. Here's how the Tapbots guys and some regular expressions single-handedly made my Twitter replies usable again.

    **Lots and lots of user mentions**

    The top #wrongryan offender is, believe it or not, teenage Twitter users in Malaysia who blast out tweets with up to a dozen of their friends' first names. There's no pattern, and no awareness that the replies are all pointing to the wrong people. And as it happens, apparently Ryan is a popular first name.
    ```
    (@\w+,?){3,}@[Rr]yan
    ```

    **Multi-RTs**

    The second worst offender: basically the same mention spam above, but a variant where these kids are using a lots of old school retweets instead all those first names. This regex kills anything with multiple `RT`s in a single post.
    ```
    RT[^RT]+RT
    ```

    **Quotes immediately preceding the reply**

    For some reason a LOT of erroneous tweets to me look something like `"@ryan` (note the preceding quotation). Don't ask me why.
    ```
    [“"]@[Rr]yan
    ```

    **All caps**

    An lot of wrongryans come in the form of all caps. As usual, don't ask me why. But I'm pretty sure I've never seen an intentional reply come in this way.
    ```
    @[R][Y][A][N]
    ```

    **Truncated mentions of other Ryans**

    I see this one a lot specifically when retweets of TechCrunch articles by @RyanLawler get truncated. This version uses a single elipsis character or standard three periods (thanks @noahhendrix!).
    ```
    @[Rr]yan(…|\.{3,})$
    ```


    **Anti-Seacrest**

    Duh. Also, his name is occasionally typoed as "seacret". Okay.
    ```
    [Ss]ecre(s??)t
    ```

    **Anti-Sheckler**

    Apparently the kids these days often try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler".
    ```
    [Ss]hec(k??)ler
    ```

    **Anti-Paul Ryan**

    Fun tip: left and right alike, people who wrongryan on Paul Ryan's name tend to be nut jobs. And most make the same mistake. I also pair this with any mentions of `@romney`, which really does it.
    ```
    Paul @[Rr]yan
    ```

    **Anti-Ryan Murphy**

    This guy does the Glee show, right? Gleeks aren't very excellent at Twittering.
    ```
    @[Rr]yan Murphy
    ```

    **Anti-other Ryans**

    Oh, there are so, so many. I've just completely filtered out anything including:
    * Gosling
    * Lochte
    * Boyce
    * Beatty
    * Higa (with preceding space, so as not to filter out words like "Michigan")

    ## Hat tip!
    The nerds in the audience can probably tell that I'm not very good at regex. So a big ass tip of the hat to Githubbers [Justin](http://github.com/justin) and [imathis](http://github.com/imathis) for their [awesome](https://github.com/justin/SilencedBots) [filters](https://gist.github.com/3006330).
  8. ryanblock revised this gist Aug 29, 2012. 1 changed file with 80 additions and 0 deletions.
    80 changes: 80 additions & 0 deletions ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    ## How Tweetbot and regex made my Twitter replies usable again
    As it turns out, most normal humans are incapable of learning to use Twitter @ replies. And in case you don't follow me on Twitter: yes, my handle (@ryan) gets a lot of erroneous mentions. (The most amusing, random ones I've even taken to retweeting under the #wrongryan hashtag.)

    Then Tweetbot -- and its ability to use regex as Twitter filters -- came along. Here's how the Tapbots guys and some regular expressions single-handedly made my Twitter replies usable again.

    **Lots and lots of user mentions**

    The top #wrongryan offender is, believe it or not, teenage Twitter users in Malaysia who blast out tweets with up to a dozen of their friends' first names. There's no pattern, and no awareness that the replies are all pointing to the wrong people. And as it happens, apparently Ryan is a popular first name.
    ```
    (@\w+,?){3,}@[Rr]yan
    ```

    **Multi-RTs**

    The second worst offender: basically the same mention spam above, but a variant where these kids are using a lots of old school retweets instead all those first names. This regex kills anything with multiple `RT`s in a single post.
    ```
    RT[^RT]+RT
    ```

    **Quotes immediately preceding the reply**

    For some reason a LOT of erroneous tweets to me look something like `"@ryan` (note the preceding quotation). Don't ask me why.
    ```
    [“"]@[Rr]yan
    ```

    **All caps**

    An lot of wrongryans come in the form of all caps. As usual, don't ask me why. But I'm pretty sure I've never seen an intentional reply come in this way.
    ```
    @[R][Y][A][N]
    ```

    **Truncated mentions of other Ryans**

    I see this one a lot specifically when retweets of TechCrunch articles by @RyanLawler get truncated. This version uses a single elipsis character or standard three periods (thanks @noahhendrix!).
    ```
    @[Rr]yan(…|\.{3,})$
    ```


    **Anti-Seacrest**

    Duh. Also, his name is occasionally typoed as "seacret". Okay.
    ```
    [Ss]ecre(s??)t
    ```

    **Anti-Sheckler**

    Apparently the kids these days often try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler".
    ```
    [Ss]hec(k??)ler
    ```

    **Anti-Paul Ryan**

    Fun tip: left and right alike, people who wrongryan on Paul Ryan's name tend to be nut jobs. And most make the same mistake. I also pair this with any mentions of `@romney`, which really does it.
    ```
    Paul @[Rr]yan
    ```

    **Anti-Ryan Murphy**

    This guy does the Glee show, right? Gleeks aren't very excellent at Twittering.
    ```
    @[Rr]yan Murphy
    ```

    **Anti-other Ryans**

    Oh, there are so, so many. I've just completely filtered out anything including:
    * Gosling
    * Lochte
    * Boyce
    * Beatty
    * Higa (with preceding space, so as not to filter out words like "Michigan")

    ## Hat tip!
    The nerds in the audience can probably tell that I'm not very good at regex. So a big ass tip of the hat to Githubbers [Justin](http://github.com/justin) and [imathis](http://github.com/imathis) for their [awesome](https://github.com/justin/SilencedBots) [filters](https://gist.github.com/3006330).
  9. ryanblock created this gist Aug 29, 2012.
    86 changes: 86 additions & 0 deletions @ryan tweetbot regex.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@
    ## How Tweetbot and regex made my Twitter replies usable again
    As it turns out, most normal humans are incapable of learning to use Twitter @ replies. And in case you don't follow me on Twitter: yes, my handle (@ryan) gets a lot of erroneous mentions. (The most amusing, random ones I've even taken to retweeting under the #wrongryan hashtag.)

    Then Tweetbot -- and its ability to use regex as Twitter filters -- came along. Here's how the Tapbots guys and some regular expressions single-handedly made my Twitter replies usable again.

    **Lots and lots of user mentions**

    The top #wrongryan offender is, believe it or not, teenage Twitter users in Malaysia who blast out tweets with up to a dozen of their friends' first names. There's no pattern, and no awareness that the replies are all pointing to the wrong people. And as it happens, apparently Ryan is a popular first name.
    ```
    (@\w+,?){3,}@[Rr]yan
    ```

    **Multi-RTs**

    The second worst offender: basically the same mention spam above, but a variant where these kids are using a lots of old school retweets instead all those first names. This regex kills anything with multiple `RT`s in a single post.
    ```
    RT[^RT]+RT
    ```

    **Quotes immediately preceding the reply**

    For some reason a LOT of erroneous tweets to me look something like `"@ryan` (note the preceding quotation). Don't ask me why.
    ```
    [“"]@[Rr]yan
    ```

    **All caps**

    An lot of wrongryans come in the form of all caps. As usual, don't ask me why. But I'm pretty sure I've never seen an intentional reply come in this way.
    ```
    @[R][Y][A][N]
    ```

    **Truncated mentions of other Ryans**

    I see this one a lot specifically when retweets of TechCrunch articles by @RyanLawler get truncated. This version uses a single elipsis character.
    ```
    @[Rr]yan…$
    ```

    **Truncated mentions of other Ryans**

    See above; this version uses three periods. Yes, I could probably combine the two, but I'm lazy and regex is hard for my tiny brain.
    ```
    @[Rr]yan...$
    ```

    **Anti-Seacrest**

    Duh. Also, his name is occasionally typoed as "seacret". Okay.
    ```
    [Ss]ecre(s??)t
    ```

    **Anti-Sheckler**

    Apparently the kids these days often try to tweet at someone named Ryan Sheckler, who, Wikipedia tells me, is a professional skateboarder with an MTV show. Many also typo his name "shecler".
    ```
    [Ss]hec(k??)ler
    ```

    **Anti-Paul Ryan**

    Fun tip: left and right alike, people who wrongryan on Paul Ryan's name tend to be nut jobs. And most make the same mistake. I also pair this with any mentions of `@romney`, which really does it.
    ```
    Paul @[Rr]yan
    ```

    **Anti-Ryan Murphy**

    This guy does the Glee show, right? Gleeks aren't very excellent at Twittering.
    ```
    @[Rr]yan Murphy
    ```

    **Anti-other Ryans**

    Oh, there are so, so many. I've just completely filtered out anything including:
    * Gosling
    * Lochte
    * Boyce
    * Beatty
    * Higa (with preceding space, so as not to filter out words like "Michigan")

    ## Hat tip!
    The nerds in the audience can probably tell that I'm not very good at regex. So a big ass tip of the hat to Githubbers [Justin](http://github.com/justin) and [imathis](http://github.com/imathis) for their [awesome](https://github.com/justin/SilencedBots) [filters](https://gist.github.com/3006330).