private static String getUnmatchedBrackets(final String initialText) {
   String text = initialText.replaceAll("\\\\.", "_"); // Remove escaped characters.
   text = text.replaceAll("'.'", "_"); // Remove character literals.
   text = text.replaceAll("\"([^\\n]*?)\"", "_"); // Remove string literals.
   text = text.replaceAll("/\\*(?s).*?\\*/", "_"); // Remove C comments.
   text = text.replaceAll("//[^\\n]*", "_"); // Remove C++ comments.
   StringBuilder unmatchedBrackets = new StringBuilder();
   for (int i = 0; i < text.length(); ++i) {
     char ch = text.charAt(i);
     if (PBracketUtilities.isOpenBracket(ch) && ch != '<') {
       unmatchedBrackets.append(ch);
     } else if (PBracketUtilities.isCloseBracket(ch) && ch != '>') {
       char openBracket = PBracketUtilities.getPartnerForBracket(ch);
       int lastCharIndex = unmatchedBrackets.length() - 1;
       if (lastCharIndex >= 0 && unmatchedBrackets.charAt(lastCharIndex) == openBracket) {
         unmatchedBrackets.deleteCharAt(lastCharIndex);
       } else {
         unmatchedBrackets.append(ch);
       }
     }
   }
   return unmatchedBrackets.toString();
 }