剑指Offer 第20题 判断字符串是否是数字の正则表达式

#include <regex>

regex pat1("[+-]?\\.\\d+([eE][+-]?\\d+)?");
regex pat2("([+-]?\\d+)(\\.(\\d+)?)?([eE][+-]?\\d+)?");

bool isNumericOfMine(const char *str)
{
    if(str == NULL)
    {   
        return false;
    }   
    if(regex_match(str, pat2) || regex_match(str, pat1))
    {   
        //cout << temp << "Regex Mathch!" << endl;
        return true;
    }   
    else
    {   
        //cout << temp << "Regex Not Mathch!" << endl;
        return false;
    }   
}

全部评论

相关推荐

xdu通信dddd:我小米都面完两个月了 八月底面完的,现在还是显示面试中,没有比我恐怖的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务