Symbian上使用正则表达式

来源:互联网 发布:2017淘宝新店破零 编辑:程序博客网 时间:2024/05/22 09:02

1. http://www.regexlab.com/ 下载 则表达式库 deelx.h, 是一个模板库。

2. 添加到inc目录,
    添加include目录/epoc32/include/libc
    添加lib库estlib.lib

3. 添加测试代码:

libc里的isascii方法是宏定义,需要改为函数实现。
#undef isascii
TInt isascii(TInt _C)
{
 return ((TUint)(_C)<=0177);
}

#include "deelx.h"

void CMoinView::RegExp()
{
 const TText* string =(const TText*) L"shushengsky02@163.com";
 const TText* module =(const TText*) L"^([0-9a-zA-Z]([-.//w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-//w]*[0-9a-zA-Z])*//.)+[a-zA-Z]{2,9})$";
 // declare
 static CRegexpT<TText>regexp(module);

 // test
 MatchResult result = regexp.MatchExact(string);

 // matched or not
 TInt match = result.IsMatched();
}