C++ 如何获取`data=";之间的所有字符串`“和”呢?

C++ 如何获取`data=";之间的所有字符串`“和”呢?,c++,regex,algorithm,winapi,stl,C++,Regex,Algorithm,Winapi,Stl,如何获取以下字符串中data=“和”之间的所有字符串?谢谢! L"list c s data=\"vi\" c c s data=\"việt nam\" c c s data=\"việt nam ơi\" list" //vi //việt nam //việt nam ơi #包括 #包括 #包括 #包括 /* * */ int main(int argc,字符**argv){ std::string beg(“数据=\”); std::字符串en(“\”); 字符串s(“列表CS数据

如何获取以下字符串中
data=“
之间的所有字符串?谢谢!

L"list c s data=\"vi\" c c s data=\"việt nam\" c c s data=\"việt nam ơi\" list"
//vi
//việt nam
//việt nam ơi
#包括
#包括
#包括
#包括
/*
* 
*/
int main(int argc,字符**argv){
std::string beg(“数据=\”);
std::字符串en(“\”);
字符串s(“列表CS数据=\“vi\”CS数据=\“việt nam \“c s数据=\”việt namơi \“列表”);
std::string::迭代器itBeg=s.begin();
std::string::迭代器itEnd;
while(s.end()!=(itBeg=std::search(itBeg,s.end(),beg.begin(),beg.end())){
itEnd=std::search(itBeg+beg.size()、s.end()、en.begin()、en.end());
字符串字;
std::copy(itBeg+beg.size(),itEnd,word.begin());

std::cout搜索
data=“
,然后搜索
。谁需要正则表达式?没有
data=“
。您需要我假定的转义引号。通常
/data=“([^”]*)”/
是enough@chris怎么样
data=“Hi\”John“
?@mfontani,这是一个值得关注的问题。这取决于OP是否需要处理它,但你必须确保知道相同字符的开头和结尾引号之间的区别。
#include <string>
#include <algorithm>
#include <iostream>
#include <iterator>
/*
 * 
 */
int main(int argc, char** argv) {

  std::string beg("data=\"");
  std::string en("\"");
  std::string s("list c s data=\"vi\" c c s data=\"việt nam\" c c s data=\"việt nam ơi\" list");

  std::string::iterator itBeg = s.begin();
  std::string::iterator itEnd;

  while(s.end() != (itBeg = std::search(itBeg, s.end(), beg.begin(), beg.end()))) {

      itEnd = std::search(itBeg + beg.size(), s.end(), en.begin(), en.end());
      std::string word;
      std::copy(itBeg + beg.size(), itEnd, word.begin());

      std::cout << "Word:" << word.c_str() << std::endl;
      itBeg = itEnd;
  }
  return 0;
}