int BetweenEx(CString str, CString leftstr, CString rightstr, CStringArray &strarr)
{
int leftIndex = str.Find(leftstr);
int leftLength = leftstr.GetLength();
int rightIndex = 0;
while (leftIndex != -1)
{
rightIndex = str.Find(rightstr, leftIndex + leftLength);
if (rightIndex == -1)
break;
strarr.Add(str.Mid(leftIndex + leftLength, rightIndex - leftIndex - leftLength));
leftIndex = str.Find(leftstr, rightIndex + 1);
}
return strarr.GetSize();
}
void COpencodeDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
CStringArray TmpArr;
BetweenEx(L"'1','2','3','4','5','6'", L"'", L"'", TmpArr);
for (int i = 0; i < TmpArr.GetSize(); i++)
{
AfxMessageBox(TmpArr.GetAt(i));
}
}