#include "pch.h"
|
//#include "StdAfx.h"
|
#include "Utils.h"
|
#include <list>
|
#include <regex>
|
using namespace std;
|
void DivideStringToArray(const CString& strSrc, const CString& strSeparator, CStringArray &arrayDest)
|
{
|
int startIndex = 0;
|
while(startIndex < strSrc.GetLength())
|
{
|
int endIndex = strSrc.Find(strSeparator , startIndex);
|
|
if (endIndex == -1)
|
{
|
endIndex = strSrc.GetLength();
|
}
|
|
arrayDest.Add(
|
strSrc.Mid(startIndex , endIndex - startIndex));
|
|
startIndex = endIndex + strSeparator.GetLength();
|
}
|
}
|
|
|
void MergeArrayToString(const CStringArray &arraysrc , const CString& strSeparator, CString &strDest)
|
{
|
int count = arraysrc.GetCount();
|
|
if (count <= 0)
|
{
|
return;
|
}
|
strDest = arraysrc[0];
|
|
for (int n = 1 ; n < count ; ++n)
|
{
|
strDest += strSeparator + arraysrc[n];
|
}
|
}
|
|
CString PZStrToCString(const char * pzstr)
|
{
|
return CStrA2CStrT(pzstr);
|
}
|
|
|
|
int RegexMatch(const CString& line, const CString& reg, CString results[])
|
{
|
string sline=CString2String(line);
|
regex sreg(CString2String(reg));
|
smatch matchresults;
|
|
int count = 0;
|
if (regex_match(sline,matchresults,sreg))
|
{
|
for (int i=0; i<matchresults.size(); ++i)
|
{
|
results[count++] = String2CString(matchresults[i]);
|
}
|
}
|
return count;
|
}
|
|
int RegexMatchNoCase(const CString& line, const CString& reg, CString results[])
|
{
|
CString lineLower = line;
|
CString regLower = reg;
|
lineLower.MakeLower();
|
regLower.MakeLower();
|
return RegexMatch(lineLower, regLower, results);
|
}
|