c++不用 boost 库,怎么切割字符串?

2018 年 8 月 8 日
 wsds

不用 boost 库,最简单的方式, 怎么拿到 test123

test/test123
4524 次点击
所在节点    程序员
26 条回复
v2qwsdcv
2018 年 8 月 9 日
araraloren
2018 年 8 月 9 日
~~ 推荐 strtok 的都是什么心态。。
mingl0280
2018 年 8 月 9 日
string s("test/test123");
int lastSlash = s.rfind('/');
if (lastSlash != s::npos)
string t = s.substr(lastSlash+1);

t 就是结果。
mingl0280
2018 年 8 月 9 日
@agostop 基本不用 boost 路过
yazoox
2018 年 8 月 9 日
也挺好奇的,现在 c++都用什么库?
裸的 c++用起来,真的老费劲了......
dychenyi
2018 年 8 月 9 日
23 是最简单的写法。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.ih06.com/t/478040

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX