از regex استفاده کنید:
#include <regex>
#include <iostream>
using namespace std;
int main()
{
string int_num = "^0$|^[1-9][0-9]*$";
regex pattern(int_num);
std::smatch match;
std::string str;
cout << "enter token:";
cin >> str;
if (std::regex_match(str, match, pattern))
{
cout << "true" << endl;
}
else cout << "false" << endl;
}