private String restoreGroupingAndWhitespace(String source, List<Integer> groups,
			List<String> whitespace, InputMode mode) {

		// First remove all whitespace.
		source = source.replaceAll("\\s", "");

		// Now set up the mode modifier.
		int modeModifier = (mode == InputMode.BINARY) ? 8 : 2;

		// Now set up a counter to track our position in the whitespace list.
		int whitespaceIndex = 0;

		// Now loop over all the groups, breaking up our source string and adding whitespaces.
		StringBuilder sb = new StringBuilder();
		for (Integer group : groups) {
			sb.append(source.substring(0, group * modeModifier));

			if (whitespaceIndex < whitespace.size()) {
				sb.append(whitespace.get(whitespaceIndex));
				whitespaceIndex++;
			}

			// And chop off the part of the string we just processed for the next iteration.
			source = source.substring(group * modeModifier);
		}

		return sb.toString();
	}
Takes the given string and puts spaces on the boundaries defined by the groups passed
in. 

eg: if the source is "AA BBBB CC DDDDDD" and the groups are {2, 1, 4}, and the
whitespace list is {5, 1} the returned string will be "AABB     BB CCDDDDDD".

Note that the mode passed in determines how we interpret group sizes. If the mode is HEX
then a group size of '2' will mean 4 characters (2 bytes), but if the mode is BINARY then
we'll grab 16 characters for that group of 2.
    
@param source the input string
@param groups the list of group sizes
@param whitespace the list of whitespace strings
@param mode binary or hex
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/SelectionModeWidget.java