文章目录
字符串分割
-
- 字符串分割
void String_Split(std::string s, std::string delim, std::vector&ans) { std::string::size_type pos_1, pos_2 = 0; while (pos_2 != s.npos) { pos_1 = s.find_first_not_of(delim, pos_2); if (pos_1 == s.npos)break; pos_2 = s.find_first_of(delim, pos_1); ans.push_back(s.substr(pos_1, pos_2 - pos_1)); } }
std::vectorsplit(std::string s, char token){ std::stringstream iss(s); std::string word; std::vectorvs; while(getline(iss,word,token)){ vs.push_back(std::atof(word.c_str())); } return vs; }
bool getSubstr(std::string string_in, char char1, char char2, std::string &sub_get, std::string &a