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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -