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

全部评论

相关推荐

兑生:一开始只是想找个实习,找到实习了想进大厂,进大厂了想转正,转正了想offer打牌,打牌了想要大包,大包了想要wlb……
点赞 评论 收藏
分享
2025-11-26 14:42
郑州轻工业大学 Java
在写周报的打工人很独...:这个笔试昨天晚上做了一下,真难啊,前后端,ai全有
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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