限定1-2048中的整数
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main()
{
//(?!patte_n)非获取匹配,正向否定预查,
//在任何不匹配pattern的字符串开始处匹配查找字符串,
//该匹配不需要获取供以后使用。
//例如“Windows(?!95|98|NT|2000)”能匹配“Windows3.1”中的“Windows”,
//但不能匹配“Windows2000”中的“Windows”。
//后边限定截取6个字符长度例如 1234567 只能识别123456 加上7以后则不符合长度内容
//regex reg("[1-9]\\d{5}(?!\\d)");
//regex reg("^(0?[1-9])$");//|(0?20[0-4][0-8])
regex reg("([1-9])|([1-9][0-9])|([1-9]\\d{2})|(1\\d{3})|(20[0-4][0-8])");//{1,2}最少出现一次 最多出现2两次
string str;
while (1)
{
cin >> str;
bool isit = regex_match(str, reg);
if (isit)
{
cout << "isit" << endl;
}
}
return 0;
}