Combine one or more inclusion regex with one or more exclusion regex to form a single exclusion regex. This is based on a negative forward lookup to turn an inclusion into an exclusion.
^((?!(
regexp_to_invert)).)*$
# takes single regexp as string or multiple as array, or nil
def make_exclusion_regexp(i,e) # include,exclude
i=[i] unless i.class==Array
i=i.reject{|x|x.nil? or x.empty?}
i=['.*'] if i.size==0
e=[e] unless e.class==Array
e=e.reject{|x|x.nil? or x.empty?}
# turns the include list into an exclude list by using a negative forward
# lookup.
inverted_inclusion="^((?!("+i.join("|")+")).)*$"
# add our new exclusion to exclusion array
e.push(inverted_inclusion)
return "("+e.join("|")+")"
end