展会信息港展会大全

Cocos2d-x学习笔记(一)
来源:互联网   发布日期:2015-09-27 15:11:34   浏览:1919次  

导读: Cocos2d 中一些验证正则表达式: 邮箱: #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) regex pattern("([...

Cocos2d 中一些验证正则表达式:

邮箱:

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)

regex pattern("([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)");

if (! std::regex_match(m_pRegEmail->getText(), pattern)){

return false;

}

#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

std::regex_t match_regex;

regcomp(&match_regex,"([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)",REG_EXTENDED);

if (regexec(&match_regex, m_pRegEmail->getText(), 0, NULL, 0) != 0){

return false;

}

regfree(&match_regex);

#endif

是否包含英文:

bool includeChinese(const char *str)

{

char c;

while (1)

{

c = *str++;

if (c == 0) break;//

if (c & 0x80)//

if (*str & 0x80) return true;

}

return false;

}

赞助本站

人工智能实验室
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港