Cocos2d-x Study Notes (1)

Source: Internet
Author: User

Cocos2d-x Study Notes (1)

Some validation Regular Expressions in Cocos2d:

Email:

#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

Include English or not:

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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.