regex - How to QRegExp "[propertyID="anything"] "? -


i parsing file contains following packets:

[propertyid="123000"] {    fillcolor : #f3f1ed;   minsize : 5;   linewidth : 3; } 

to scan [propertyid="123000"] fragment havre qregexp

qregexp("^\b\[propertyid=\"c+\"\]\b"); 

but not work? here have example code parse file above:

qregexp propertyidexp= qregexp("\\[propertyid=\".*\"]"); propertyidexp.setminimal(true);  qfile inputfile(filename); if (inputfile.open(qiodevice::readonly)) {     qtextstream in(&inputfile);     while (!in.atend())     {         qstring line = in.readline();          // if not catch if line instance         // [propertyid="123000"] {         if( line.contains(propertyidexp) )         {             //.. further processing         }     }     inputfile.close(); } 

qregexp("\\[propertyid=\".+?\"\\]") 

you can use ..it match character except newline.also use +? make non greedy or stop @ last instance of " in same line


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -