Good day!
In the line, what is in {....} is called a comment. How to remove all comments from the line? Desirable with an explanation. I can only delete 1 comment :(
public static void main(String[] args) { String s = "bla bla {za4em nado } bla bla { za4em nado} bla"; int p = s.indexOf("{"); int t = s.indexOf("}"); String res; if (p == -1) { res = s; } else { res = s.substring(0, p)+ s.substring(t+1); } System.out.println(res); }