Got the answer with some help from Rainer Gerhards:
if $programname == 'program1' and $msg contains 'an expression' then /dev/null
& stop
Note that for older versions of rsyslog (like V5 that Ubuntu provided with their V13 'Saucy'), you must use single quotes around the attributes. Double quotes work in late mode rsyslog versions like rsyslog V7