TPRegexp MatchS returning just the first occurrence

I am trying to retrieve:

from the string:
(nic.nHit>=75)&&(mic.cFitStatus==0)&&(mic.aFitStatus==0)&&(mic.NxPL10xChanel>60)&&(mic.Scale<100)&&(mic.zAngle180.00/3.14159 < 20)&&(mic.nChaAv>0)&&(1.0mic.nHit>=0.3*mic.nChaAv)

Here is my code:

    TString subStr;
    TObjArray *subStrL = TPRegexp("[a-z]+\\.[a-zA-Z]+").MatchS("(nic.nHit>=75)&&(mic.cFitStatus==0)&&(mic.aFitStatus==0)&&(mic.NxPL10xChanel>60)&&(mic.Scale<100)&&(mic.zAngle*180.00/3.14159 < 20)&&(mic.nChaAv>0)&&(1.0*mic.nHit>=0.3*mic.nChaAv)");
    for (Int_t i = 0; i < subStrL->GetLast()+1; i++) {
       subStr = ((TObjString *)subStrL->At(i))->GetString();
       std::cout << "\"" << subStr << "\" ";

and the output:



I’d have a question before diving into the actual issue you are trying to solve.
It seems that you are trying to match something like “branch.leaf” or “object.datamember” within a cut expressed as a string, perhaps having more context about the big picture may help…

Yes, you are right, probably there is a simple way to solve my problem.
I have an ASCII file with the cuts, the first thing that I do is read it and keep it as a TString (string_cuts) before applying it as a cut in

TTree *new_tree = old_tree->CopyTree(string_cuts);

The problem comes when a “branch.leaf” in the cuts does not exist in the old_tree. That is the reason I want to create an TObjArray with the “branches.leafs” from the string_cuts and then check one by one if exist in the old_tree.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.