I Have a CString (MFC) which contains the following three conditions separated as follows.


I am trying to extract the three conditions from the CString and use them to perform other operations. However I cant seem to find the right built-in function.

Could someone please advise on what the best way to do this will be? Cant seem to find a function which can strip away to the left and right of the "|" operator.

Thanks in advance.

CString has Left(), Right(), and Mid() methods which are something like std::string's substr() method.

Thanks, stupid question i suppose...

I've always found AfxExtractSubString() to be useful for that kind of thing. Not a particularly well documented function but it's there and it works.

BOOL AFXAPI AfxExtractSubString (
   CString& rString,
   LPCTSTR lpszFullString,
   int iSubString,
   TCHAR chSep = '\n'

set lpszFullString to "Condition1|condition2|Condition3",
set chSep to '|'
set iSubString to 0,1 or 2
and you'll get rString returned as "Condition1", "Condition2", or "Condition3".