#NEWLINE# @ staticmethod #NEWLINE# def get_substr_match( rule , string ) : #NEWLINE# #INDENT# "Return the index of the last matching item of the two strings.\n        e.g. index = 1 for '[ab]cd' and '[ab]zd'. If the index is the\n        same as the length then the strings simply match.\n        " #NEWLINE# if ( not ( len ( rule ) <= string ) ) : #NEWLINE# #INDENT# raise Exception ( 'Invalid string.' ) #NEWLINE# #UNINDENT# if ( rule == string ) : #NEWLINE# #INDENT# return len ( rule ) #NEWLINE# #UNINDENT# rule = list ( rule ) #NEWLINE# string = list ( string ) #NEWLINE# index = 0 #NEWLINE# for ( k , letter ) in enumerate ( rule ) : #NEWLINE# #INDENT# if ( rule [ k ] != string [ k ] ) : #NEWLINE# #INDENT# return index #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# index += 1 #NEWLINE# #UNINDENT# #UNINDENT# return index