VC9.0 SP1 TR1 中新加入的正则表达式
在 VC9.0 SP1出现前,如果要使用正则表达式,是一件很麻烦的事。GRETA和CAtlRegExp对标准的支持并不好,连简单的{m,n}限定符都不支持
boost和pcre都需要额外引入。
SP1中的 TR1 终于加入了 标准化的 正则表达式库。
今天有幸使用了一回,和boost基本一样,就命名控件发生了改变。
#include <regex>#include <string>using namespace std;using namespace std::tr1;wstring wszFileName = T2W(stFind.cFileName);wregex oRegex(L"^(([^\\d]+)(\\d+)(\\.png))$", regex_constants::ECMAScript | regex_constants::icase);if( regex_search( wszFileName.c_str(), oMatch, oRegex) ){if( oMatch.size() > 3 ){int nPageIndex = _wtoi(oMatch.first);}}
页:
[1]