I have a vector containing strings that follow the format of text_number-number
vector
strings
text_number-number
Eg: Example_45-3
Example_45-3
Check this out
std::string ex = "Example_45-3"; int num; sscanf( ex.c_str(), "%*[^_]_%d", &num );