public static String trimString(String string) {
		// short-circuit case where the given string starts normally, but contains invalid
		// characters (e.g., param_1[EAX])
		StringBuilder buffer = new StringBuilder(string);
		if (Character.isJavaIdentifierPart(buffer.charAt(0))) {
			// in this case just take all valid characters and then exit
			for (int index = 1; index < buffer.length(); index++) {
				int charAt = buffer.charAt(index);
				if (!Character.isJavaIdentifierPart(charAt)) {
					return buffer.substring(0, index);
				}
			}
			return buffer.toString();
		}

		// the following case is when the given string is surrounded by "goofy" characters
		int index = 0;
		int charAt = buffer.charAt(index);
		while (!Character.isJavaIdentifierPart(charAt) && buffer.length() > 0) {
			buffer.deleteCharAt(0);
			charAt = buffer.charAt(0);
		}

		index = buffer.length() - 1;
		charAt = buffer.charAt(index);
		while (!Character.isJavaIdentifierPart(charAt) && index > 0) {
			buffer.deleteCharAt(index);
			charAt = buffer.charAt(--index);
		}

		return buffer.toString();
	}
Trims unwanted characters off of the given label, like spaces, '[',']', etc.
@param string The string to be trimmed
@return The trimmed string.
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldUtils.java