in reply to Set theory in regexs

I hope I am understanding your question correctly. This little piece of code takes a string delimited by spaces, splits it up into a list, and exits with a true flag if any one element of the list contains exactly one letter followed by exactly one digit.
use strict; my $string = 'bar a2 b2 c3 d3 d4 a1 f2 f3'; my $flag = 0; foreach(split(/\s+/, $string)) { $flag++, last if /\w\d/; } print "foo's found in list\n" if $flag;
If you wanted to specify a list of foo's to match against, such as only d4 or b2, you could try this instead . . .
use strict; my @foos = qw(d4 b2); my $string = 'bar a2 b2 c3 d3 d4 a1 f2 f3'; my $flag = 0; foreach my $cand (split(/\s+/, $string)) { foreach(@foos) { $flag++, last if $cand =~ /$_/; } } print "foo's found in list\n" if $flag;
Hope this helps, Jeff

UPDATE: Oops, you wanted d4 AND b2 - luckily for me, merlyn has got you covered . . .