static String escapeSomeRegexCharacters(String input, char[] doNotEscape) {
		//  
		// Note: we have to handle backslash characters specially, since we have to look at the
		// character that follows the backslash.
		//
		// This search utility allows users to perform globbing operations
		// using '*' and '?'. To disable that feature, users can escape those specific characters 
		// using a backslash. Except for these special cases, we want to treat backslashes 
		// literally, assuming users wish to search for backslash characters.
		//
		// Escape any '\' characters that are not followed by a globbing char
		//
		Matcher backslashMatcher = NON_GLOB_BACKSLASH_PATTERN.matcher(input);
		String updated = backslashMatcher.replaceAll("\\\\\\\\");

		// Escape all other regex chars individually with a backslash 
		StringBuilder buffy = new StringBuilder();
		for (int i = 0; i < updated.length(); i++) {
			char c = updated.charAt(i);

			if (contains(doNotEscape, c)) {
				// a bit inefficient, but the array should always be short
				buffy.append(c);
				continue;
			}

			switch (c) {
				case '^':
					buffy.append("\\^");
					break;
				case '.':
					buffy.append("\\.");
					break;
				case '$':
					buffy.append("\\$");
					break;
				case '(':
					buffy.append("\\(");
					break;
				case ')':
					buffy.append("\\)");
					break;
				case '[':
					buffy.append("\\[");
					break;
				case ']':
					buffy.append("\\]");
					break;
				case '+':
					buffy.append("\\+");
					break;
				case '&':
					buffy.append("\\&");
					break;
				case '{':
					buffy.append("\\{");
					break;
				case '}':
					buffy.append("\\}");
					break;
				case '*':
					buffy.append("\\*");
					break;
				case '?':
					buffy.append("\\?");
					break;
				case '|':
					buffy.append("\\|");
					break;
				default:
					buffy.append(c);
					break;
			}
		}
		return buffy.toString();
	}
Escapes all regex characters with the '\' character, except for those in the given exclusion 
array.

@param input The input string to be escaped
@param doNotEscape an array of characters that should not be escaped
@return A new regex string with special characters escaped.
Ghidra/Framework/Utility/src/main/java/ghidra/util/UserSearchUtils.java