tstring trim(const tstring &tstr, const tstring& trimChars) { size_t s = tstr.find_first_not_of(trimChars); size_t e = tstr.find_last_not_of (trimChars); if ((tstring::npos == s) || ( tstring::npos == e)) return _T(""); else return tstr.substr(s, e - s + 1); }
void trim(tstring& str, char ch) { tstring::size_type pos = str.find_first_not_of(ch); if (pos == tstring::npos) { str = _T(""); return; } tstring::size_type pos2 = str.find_last_not_of(ch); if (pos2 != tstring::npos) { str = str.substr(pos, pos2 - pos + 1); } else { str = str.substr(pos); } }
tstring TriToken(tstring& Token){ tstring::size_type begin = Token.find_first_not_of(_T(' ')); if(begin == string::npos)return Token; tstring::size_type end = Token.find_last_not_of(_T(' ')); return Token.substr(begin,end-begin+1); }