in reply to Non-exclusive or in regexp?

You can do something like this to get your desired results Effectively we only do the substitution if we have a match in $2 as well as $1 which means we have to have "SOMETHING rice" where SOMETHING is the maximum non exclusive OR of the presented cases.....

my $jdsc = qr/(?:national\s+security\s+adviser\s+)/; my $title = qr/(?:dr.|doctor)\s+/; my $fn = qr/(?:condoleeza\s+)/; my $sn = qr/rice/; my $repl = 'condoleezarice'; while(<DATA>){ s{ ( ( $jdsc? $title? $fn? ) $sn ) } { $2 ? $repl : $1 }exig; print; } __DATA__ white rice dr. rice doctor rice dr. condoleeza rice doctor condoleeza rice condoleeza rice national security adviser doctor condoleeza rice

Update, I prefer Sidhekins method

s/ (?!$sn) $jdsc? $title? $fn? $sn /$repl/igx;

cheers

tachyon