在VC6中使用正規表示式解析字串

2021-09-25 08:33:26 字數 884 閱讀 4535

from:

#include #include #include #include #include using namespace std;

using namespace boost;

int main(int argc, char * ar**)

{ regex expression("(\\d+)-(\\d+)-(\\d+)"); // 注意轉義方式

string in("today: 2007-06-23");

cmatch what;

// 如果用 regex_match 方法將需要完全匹配,

// 不能在字串中找尋模式,可用於驗證輸入

if (regex_search(in.c_str(), what, expression))

{ for(int i = 0 ; i < what.size(); i++)

{ cout<<"str: "<程式執行結果:

str: 2007-06-23

str: 2007

str: 06

str: 23

press any key to continue

注意:

本文所使用的boost庫版本為:boost_1_34_0。請大家一定要看清楚了,一些高版本的boost庫已經不再支援vc6了,而是支援更高版本的visual studio ide(7.1以上)。

另外,編譯之前,需要將libboost_regex-vc6-sgd-1_34.lib拷貝到程式根目錄下,該檔案是在「nmake -f vc6.mak」時產生的。

在VC6中使用GDI

包含了標頭檔案和庫 dll和.lib形式的都有 我在編譯過程中出現了編譯錯誤 ulong ptr沒被定義。錯誤在gdiplusinit.h中 typedef status winapi notificationhookproc out ulong ptr token 一行。然後我在gdiplusin...

在 VC6 中使用 GdiPlus 使用

下面用 vc6 來寫乙個 gdiplus 的 demo 工程 step2 新增標頭檔案宣告 在 stdafx.h 中新增以下 microsoft visual c will insert additional declarations immediately before the previous ...

在UltraEdit中使用正規表示式

在ultraedit中使用正規表示式 刪除空行 替換 t p 為 空串 刪除行尾空格 替換 t 為 空串 刪除行首空格 替換 t 為 空串 每行設定為固定的4個空格開頭 替換 t t p 為 1 每段設定為固定的4個空格開頭 替換 t 為 如果一行是以空格開始的,則視之為一段的開始行 將一段合併為一...