Problem: I wrote a regular expression that looks for '{' and looks back to see if there is a sign of comments, and when it finds a given character that is not preceded by a comment, it replaces it with another sequence of characters. But alas, it does not work already what time it is. Be kind, friends, tell me where was wrong:
while (start >= 0 && end >=0) { start = text.indexOf("\n", start); end = text.indexOf(QRegExp("^.*[{](?!=[//]|[/*]|[*]))"),start); end2 = text.indexOf(QRegExp("^.*[}](?!=[//]|[/*]|[*]))"), start); if (end < end2) { text.replace(end,"\n{\n"); } else text.replace(end2,"\n}\n"); ++start; } let's say there is a text like:
//dfsdkfj ksjdfksjdf { <- этот символ должен быть пропущен public SystemBlock() { <- этот должен быть найден this.producer = "none"; this.motherBoard = "none"; this.processor = "none"; this.ram = "none"; this.gpu = "none"; this.price = 0; this.eventSupport = null; }