提交 | 用户 | age
|
3b04f9
|
1 |
#include "pch.h"
|
Q |
2 |
//#include "StdAfx.h"
|
4b03ae
|
3 |
#include "Utils.h"
|
Q |
4 |
#include <list>
|
|
5 |
#include <regex>
|
|
6 |
using namespace std;
|
|
7 |
void DivideStringToArray(const CString& strSrc, const CString& strSeparator, CStringArray &arrayDest)
|
|
8 |
{
|
|
9 |
int startIndex = 0;
|
|
10 |
while(startIndex < strSrc.GetLength())
|
|
11 |
{
|
|
12 |
int endIndex = strSrc.Find(strSeparator , startIndex);
|
|
13 |
|
|
14 |
if (endIndex == -1)
|
|
15 |
{
|
|
16 |
endIndex = strSrc.GetLength();
|
|
17 |
}
|
|
18 |
|
|
19 |
arrayDest.Add(
|
|
20 |
strSrc.Mid(startIndex , endIndex - startIndex));
|
|
21 |
|
|
22 |
startIndex = endIndex + strSeparator.GetLength();
|
|
23 |
}
|
|
24 |
}
|
|
25 |
|
|
26 |
|
|
27 |
void MergeArrayToString(const CStringArray &arraysrc , const CString& strSeparator, CString &strDest)
|
|
28 |
{
|
|
29 |
int count = arraysrc.GetCount();
|
|
30 |
|
|
31 |
if (count <= 0)
|
|
32 |
{
|
|
33 |
return;
|
|
34 |
}
|
|
35 |
strDest = arraysrc[0];
|
|
36 |
|
|
37 |
for (int n = 1 ; n < count ; ++n)
|
|
38 |
{
|
|
39 |
strDest += strSeparator + arraysrc[n];
|
|
40 |
}
|
|
41 |
}
|
|
42 |
|
|
43 |
CString PZStrToCString(const char * pzstr)
|
|
44 |
{
|
|
45 |
return CStrA2CStrT(pzstr);
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
int RegexMatch(const CString& line, const CString& reg, CString results[])
|
|
51 |
{
|
|
52 |
string sline=CString2String(line);
|
|
53 |
regex sreg(CString2String(reg));
|
|
54 |
smatch matchresults;
|
|
55 |
|
|
56 |
int count = 0;
|
|
57 |
if (regex_match(sline,matchresults,sreg))
|
|
58 |
{
|
|
59 |
for (int i=0; i<matchresults.size(); ++i)
|
|
60 |
{
|
|
61 |
results[count++] = String2CString(matchresults[i]);
|
|
62 |
}
|
|
63 |
}
|
|
64 |
return count;
|
|
65 |
}
|
|
66 |
|
|
67 |
int RegexMatchNoCase(const CString& line, const CString& reg, CString results[])
|
|
68 |
{
|
|
69 |
CString lineLower = line;
|
|
70 |
CString regLower = reg;
|
|
71 |
lineLower.MakeLower();
|
|
72 |
regLower.MakeLower();
|
|
73 |
return RegexMatch(lineLower, regLower, results);
|
|
74 |
} |