给定如下字符串:
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/