I wrote a regular expression for find the scopes('{'|'}'). I want to find the scopes that wasn't commented, but I don't understand where I have mistake. Here are a fragment of code:
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;
}
For example, we have some text:
//dfsdkfj ksjdfksjdf { <- this symbol should be skipped
public SystemBlock()
{ //<- this symbol should be found.
this.producer = "none";
this.motherBoard = "none";
this.processor = "none";
this.ram = "none";
this.gpu = "none";
this.price = 0;
this.eventSupport = null;
}