Hi I have a string like this:
word1--tab--word2--tab--word3--tab--word4--tab--word5--tab--word6
I need to extract the third word fr
assuming "tab" is \t
;
std::istringstream str(".....");
std::string temp, word;
str >> temp >> temp >> word;
std::string
has the find
method which returns an index. You can use
find("--", lastFoundIndex + 1)
three times to find the start index of your word, a fourth time for the end index, and then use substr
.