- 11 名前:デフォルトの名無しさん mailto:sage [2006/08/25(金) 23:22:57 ]
- >>6
/** 文字列を指定の文字で分割し、単語のリストを作ります @param text 入力文字列(","や";"を含む文字列) @param separators 分裂文字列(",.;:","\n") @param words 出力文字列リスト */ bool split(const string& text, const string& separators, vector<string>& words) { int n = text.length(); int start = text.find_first_not_of(separators); while ((start >= 0) && (start < n)) { int stop = text.find_first_of(separators, start); if ((stop < 0) || (stop > n)) stop = n; words.push_back (text.substr(start, stop-start)); start = text.find_first_not_of(separators, stop+1); } return true; }
|

|