gpt4 book ai didi

c++ - 如何从字符串末尾提取数字

转载 作者:可可西里 更新时间:2023-11-01 18:01:58 24 4
gpt4 key购买 nike

给定如下字符串:

   sdfsd34 
sdfdsf1

我想提取:34, 1 使用 c++(STL 但没有提升),c。

谢谢

最佳答案

您正在搜索函数 string.find_last_not_of :

string str = "sdfsd34";
size_t last_index = str.find_last_not_of("0123456789");
string result = str.substr(last_index + 1);

关于c++ - 如何从字符串末尾提取数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4072363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com