c++ - QString, Parse and replace some specific sections -


suppose have string this:

qstring str = "23+34-343+$t$-3+$opc$"; 

i want replace every sections enclosed 2 $ replaced %0, %1 , on. above example : "23+34-343+%0-3+%1"

i can detect sections using qregularexpression , pattern: "\$.+?\$"

what best , optimized way (not use loops , indices) replace sections %0, %1, %2 , on.

how this:

qstring str = "23+34-343+$t$-3+$opc$";  qregexp rx; rx.setminimal(true); rx.setpattern("\\$.+\\$"); str.replace(rx, "x");           //first replace every pattern 'x'  for(int i=0 ;str.indexof("x")!=-1; i++)     str.replace(str.indexof("x"), 1,"%"+qstring::number(i)); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -