Answers for "c++ get last numeric part of string"

C++
4

c++ get last character of string

// Example
YourStr.substr(YourStr.length() - 1)

// Syntax
std::string YourStr = "abcdef";
std::cout << YourStr.substr(YourStr.length() - 1) << "\n"; // OUTPUT: f
Posted by: Guest on May-05-2021
0

c++ string find last number

//Example
string str = "sdfsd34";

//Find the first first number and then all the number after
str.substr(str.find_first_of("0123456789"))

//Find the last number
size_t last_index = str.find_last_not_of("0123456789");
string result = str.substr(last_index + 1);
Posted by: Guest on November-22-2021

Code answers related to "c++ get last numeric part of string"

Browse Popular Code Answers by Language