private int findBalancedEnd(String string, int start, char open, char close) {

		boolean found = false;
		int depth = 0;
		for (int i = start; i < string.length(); i++) {

			char c = string.charAt(i);
			if (c == open) {
				depth++;
				found = true;
			}
			else if (c == close) {
				depth--;
			}

			if (found && depth == 0) {
				return i;
			}
		}

		return -1;
	}
Scans the given string from the given offset looking for a balanced {@code close}
character.   This algorithm will not report a match for the end character until the
{@code open} character has first been found.   This allows clients to scan from anywhere
in a string to find an open and start character combination, including at or before the
desired opening character.

@param string the input string
@param start the start position within the string
@param open the open character (e.g, '(' or '<')
@param close the close character (e.g, ')' or '>')
@return the end index; -1 if no templates found
Ghidra/Features/GnuDemangler/src/main/java/ghidra/app/util/demangler/gnu/GnuDemanglerParser.java