到达字符串中的特定单词 [英] Reaching a specific word in a string
本文介绍了到达字符串中的特定单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我有这样的字符串:
Hi I have a string like this:
word1 - tab - word2 - -word4 - tab - word5 - tab - word6
word1--tab--word2--tab--word3--tab--word4--tab--word5--tab--word6
我需要从字符串中提取第三个字。我想到按字符阅读字符和读取第二个选项卡后得到的单词。但我想它是低效率的。
I need to extract the third word from the string. I thought of reading character by character and getting the word after reading the second tab. But I guess it is inefficient. Can you show me a more specific way please?
推荐答案
假设tab是 \t
;
std::istringstream str(".....");
std::string temp, word;
str >> temp >> temp >> word;
这篇关于到达字符串中的特定单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文