Last active
August 3, 2021 20:20
-
-
Save ram1123/02030e5b55e35885e2a2b7af3c4dd250 to your computer and use it in GitHub Desktop.
Replace a string, check if sub-string is there in a string or not, Tokenize a string based on delimiter (Works within ROOT environment)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void replaceSplit() { | |
TString string1 = "GluGluToHHTo2G4Q_node_cHHH1_13TeV_HHWWggTag_1_FNUFEBDown01sigma"; | |
TString ToReplace = "HHWWggTag_1"; | |
TString ReplaceWith = "HHWWggTag_FH_1"; | |
std::cout << "==>\t" << string1 << std::endl; | |
std::cout << "==>\t" << string1.ReplaceAll(ToReplace, ReplaceWith) << std::endl; | |
std::cout << "==>\t" << string1.Contains("noda") << std::endl; | |
std::cout << "==>\t" << string1.Contains("Tag_1") << std::endl; | |
std::cout << "==>\t" << string1.Contains("Tag_FH") << std::endl; | |
TObjArray* tokens = string1.Tokenize("_"); | |
TIter next(tokens); | |
TKey *key; | |
while ( (key = (TKey*)next())) { | |
std::cout <<"==> " << key->GetName() << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment