剑指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;
    }   
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 13:54
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-07 11:35
程序员小白条:话太多,没实力和学历,差不多回答回答就行了,身份地位不一样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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