スコープ( '{' | '}')を見つけるための正規表現を書いています。私はコメントされていないスコープを見つけたいが、私はどこに間違いがあるのか理解していない。ここでは、コードの断片である:例えば正規表現の条件qt
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;
}
、我々はいくつかのテキストを持っている:すべての
//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;
}
:: '\\ {'と '\\}'
^(?!(//|/\*))*{
。それらは量的に解釈されるかもしれない。 – ilotXXI