SNp*_*Npn 4 c++ string templates split ignore
是否有类似于Java的C++拆分类型函数?我知道无视,但我不太了解它,以及它对我的情况如何有效.
我的意见是:
{
item = ball
book = lord of the rings
movie = star wars
}
Run Code Online (Sandbox Code Playgroud)
给出的输入是<attribute>= <value>并且我必须将两个存储在不同的字符串或整数中(取决于值,例如,如果它是一个数字,则使用整数).
使用Boost :: tokenizer就像你想做的那样.从手册:
// simple_example_1.cpp
#include<iostream>
#include<boost/tokenizer.hpp>
#include<string>
int main(){
using namespace std;
using namespace boost;
string s = "This is, a test";
tokenizer<> tok(s);
for(tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){
cout << *beg << "\n";
}
}
Run Code Online (Sandbox Code Playgroud)