• + 2 comments

    That is easy :)

    Just make your string to be like the one in input.

        String input=sc.next().replaceAll("[^\\(\\)\\[\\]\\{\\}]", "");
        while(input.length() != (input = input.replaceAll("\\(\\)|\\[\\]|\\{\\}", "")).length());
        System.out.println(input.isEmpty());
    

    Make note of one additional part appeared:

    .replaceAll("[^\\(\\)\\[\\]\\{\\}]", "");