def record_match_subfields(rec, tag, ind1="<STR_LIT:U+0020>", ind2="<STR_LIT:U+0020>", sub_key=None,<EOL>sub_value='<STR_LIT>', sub_key2=None, sub_value2='<STR_LIT>',<EOL>case_sensitive=True):
if sub_key is None:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if sub_key2 is not None and sub_value2 is '<STR_LIT>':<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>+ "<STR_LIT>")<EOL><DEDENT>ind1, ind2 = _wash_indicators(ind1, ind2)<EOL>if not case_sensitive:<EOL><INDENT>sub_value = sub_value.lower()<EOL>sub_value2 = sub_value2.lower()<EOL><DEDENT>for field in record_get_field_instances(rec, tag, ind1, ind2):<EOL><INDENT>subfields = dict(field_get_subfield_instances(field))<EOL>if not case_sensitive:<EOL><INDENT>for k, v in subfields.items():<EOL><INDENT>subfields[k] = v.lower()<EOL><DEDENT><DEDENT>if sub_key in subfields:<EOL><INDENT>if sub_value is '<STR_LIT>':<EOL><INDENT>return field[<NUM_LIT:4>]<EOL><DEDENT>else:<EOL><INDENT>if sub_value == subfields[sub_key]:<EOL><INDENT>if sub_key2 is None:<EOL><INDENT>return field[<NUM_LIT:4>]<EOL><DEDENT>else:<EOL><INDENT>if sub_key2 in subfields:<EOL><INDENT>if sub_value2 == subfields[sub_key2]:<EOL><INDENT>return field[<NUM_LIT:4>]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return False<EOL>
Find subfield instances in a particular field.

It tests values in 1 of 3 possible ways:
 - Does a subfield code exist? (ie does 773__a exist?)
 - Does a subfield have a particular value? (ie 773__a == 'PhysX')
 - Do a pair of subfields have particular values?
    (ie 035__2 == 'CDS' and 035__a == '123456')

Parameters:
 * rec - dictionary: a bibrecord structure
 * tag - string: the tag of the field (ie '773')
 * ind1, ind2 - char: a single characters for the MARC indicators
 * sub_key - char: subfield key to find
 * sub_value - string: subfield value of that key
 * sub_key2 - char: key of subfield to compare against
 * sub_value2 - string: expected value of second subfield
 * case_sensitive - bool: be case sensitive when matching values

:return: false if no match found, else provides the field position (int)