【发布时间】:2018-02-19 15:31:00
【问题描述】:
我试图找出两个不同字符之间的子字符串。字符串看起来像:
channelBlock_0\d_off_mux=8, 8, 8, 8, 8, 8, 8, 8
channelBlock_0\d_selvth=true, true, true, true, true, true, true, true
我想在'=' 之后和第一个',' 之前拆分
在'=' 之后剪辑已经对我有用...这是我得到的:
std::string line; //contains the string from above
std::string startDel = "=";
std::string endDel = ",";
cout << line.substr(line.find(startDel)+1,line.find(endDel));
我的输出如下所示:
8, 8, 8, 8, 8, 8, 8, 8
true, true, true, true, true
如何在第一个 ',' 之后剪切,所以我的输出只是
8
true
【问题讨论】:
-
您的问题是什么?顺便说一句,
8变成6的方式令人惊讶 -
本质上这是this的欺骗。您只需在第一次读取后将分隔符从
=更改为,。 -
按照你对
=的方式做。
标签: c++ string split substring standard-library