private static int indexOfTag( String html, String tag, boolean endIndex ) {
		int tagLength = tag.length();
		int maxLength = html.length() - tagLength - 2;
		char lastTagChar = tag.charAt( tagLength - 1 );

		for( int i = "<html>".length(); i < maxLength; i++ ) {
			// check for leading '<' and last tag name character
			if( html.charAt( i ) == '<' && Character.toLowerCase( html.charAt( i + tagLength ) ) == lastTagChar ) {
				// compare tag characters from last to first
				for( int j = tagLength - 2; j >= 0; j-- ) {
					if( Character.toLowerCase( html.charAt( i + 1 + j ) ) != tag.charAt( j ) )
						break; // not equal

					if( j == 0 ) {
						// tag found
						return endIndex ? html.indexOf( '>', i + tagLength ) + 1 : i;
					}
				}
			}
		}

		return -1;
	}
Returns start or end index of a HTML tag.
Checks only for leading '<' character and (case-ignore) tag name.
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatHTML.java