C++ 从带有 t 和空格的字符串中获取标记
c++ get tokens from a string with and empty space
假设我有一个字符串
string text = "There are many empty space and tabs inside ";
此字符串中的空格可能是 \t 或 " ",并且不确定两个标记之间有多少空格或制表符。如何从该字符串中获取令牌?哪个是更好的方法,"strtok"或"子字符串"?
使用std::istringstream
:
std::istringstream in (text);
std::vector<std::string> tokens;
for (std::string temp; in >> temp; )
tokens.push_back(temp);
相关文章:
- 从C字符串中获取奇怪的字符串长度
- 获取字符串的长度并将其分配给数组
- 我如何获取从 C++ 到 C 的映射<字符串、int>#
- 调用CreateProcess()并获取字符串的返回值
- 从字符串中获取结构的大小
- Cryptopp:获取密码输入的填充字符串
- 获取无效的字符串大小
- 获取 OID(类型::b_oid)作为 MongoDB C++驱动程序中的字符串
- C ++编译器如何获取argv字符串的长度
- 给枚举一个整数,并在 C++ 中将其相关值作为字符串获取
- 如何使用字符串获取用户控制台输入
- 通过字符串获取小部件
- 无法从字符串获取数字输入
- 在C++的静态方法中将类名作为字符串获取
- 从设备实例路径字符串获取设备实例 DWORD
- HRESULT到字符串(获取文档路径)C++
- 如何从http请求体字符串获取文件名
- 如何使用带有垃圾字符的子字符串获取字符串
- 通过字符串获取对话框项的可能性
- 有没有办法将 WinAPI 错误标志作为字符串获取