in reply to combining RegEx

Just use grouping, an alternation and a negative lookahead
my $pat = qr/ SW (?: # the grouping + alternation [:] | =? (?!ITCH) # ignore SWITCH ) \s* ([^\s;,\n\r]+) /x; my %tests = ( 'SW: foo' => 1, 'SW= bar' => 1, 'SW baz' => 1, 'SWITCH' => 0, ); while(my($test,$res) = each %tests) { print "result: ", ($res ? $1 : 'PASS'), "\n" if $res == $test =~ $pat; } __output__ result: PASS result: baz result: foo result: bar
See. perlre for more info.
HTH

_________
broquaint