Day 9 – Exclusive Selection Expressions

Goal: Be able to write exclusive select statements instead of an inclusive one

ruleset a60x489 {
  meta {
    name "exclusive-selection-expressions"
    description <<
    author "Mike Grace"
    logging on

  rule run_everywhere_on_stackoverflow {
    select when pageview "stackoverflow\.com"
      notify("Welcome to Stackoverflow","") with sticky = true;

  rule run_on_question_pages_but_not_when_asking {
    select when pageview "stackoverflow\.com/questions/(?!ask)"
      notify("Questions!","but not asking one") with sticky = true;
  • 12 selects on any URL containing ‘’
  • 19 selects on any URL containing ‘’ but only if that is not immediately followed by ‘ask’

App run on with bookmarklet

App run on a question detail page on with a bookmarklet

App run on ask a new question page on with a bookmarklet

  • Selection expressions for pageview events are currently compiled into regular expressions and then executed for matches
  • Exclusion was accomplished using a zero-width negative lookahead

Get the bookmarklet to try it out yourself!

Gratuitous day 9 crazy face

Update: 12/16/2010


I recently used this to fix one of my Kynetx apps.

The ruleset had a rule with a .* select statement

select when pageview ".*"

Problem was that doing a .* meant that it was running on my WordPress admin page which was causing some conflicts with the visual editor. To not run the rule on any WordPress admin page I changed the selection expression to use a zero width negative look ahead.

select when pageview ".*(?!wp-admin).*"

The app behaves just as before but no longer runs on any of my WordPress admin pages. 🙂

This entry was posted in Kynetx and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s