How to split and cut string in ROOT

Hi ROOT experts,
I have a string:
TString s= "/QCD_HT1000to1500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3-v2/MINIAODSIM"
How can I split and cut this string to convert into “QCD_HT1000to1500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8” in ROOT? I have many strings like this and wanna cut befor the string"pythia8".
Best regards

TString offers many functionalities to manipule and edit strings. You can search in the string the position of pythia8 with Index(), remove what is after then search for /and remove what is before…

s.Remove(s.Index("-pythia8"));
s.Remove(s.Index("/"),1);
1 Like

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