#include <string>
#include <iostream>
#include <regex>
#include <exception>

int main()
{
    std::string line;
    int num;
    //split onto multiple lines for readability
    while((std::cout <> num) && !(is >> line)) //re-using `line` to test for extra stuff after the number
    {
        break; //done, we got what we wanted
    }
    std::cerr << "Invalid input, try again." << std::endl;
}
