Symbian上使用正則表達式

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"[email protected]";
 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();
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章