public static int matchLength(byte[] array, int offset, int... pattern) {
		int patternLen = pattern.length;
		if (array == null || array.length < offset + patternLen)
			return 0;
		for (int i = 0; i < patternLen; i++) {
			int patternVal = pattern[i];
			if (patternVal == WILD)
				continue;
			if (array[offset + i] != (byte) patternVal)
				return Math.max(0, i - 1);
		}
		return patternLen;
	}
@param array
		File data to compare against.
@param offset
		Offset into the data to check at.
@param pattern
		The header pattern.

@return Length of the pattern matched by the data in the array at the given offset.
If the result is the same length as the input pattern, it is a full match.
recaf-core/src/main/java/software/coley/recaf/util/ByteHeaderUtil.java