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

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -