๐Ÿ™‡โ€โ™€๏ธSplit ๊ตฌํ˜„

Split ํ•จ์ˆ˜๋ฅผ ์ง์ ‘ ๊ตฌํ˜„ํ•˜๊ธฐ.

delimiter๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋Š์–ด์„œ ๋ฌธ์ž์—ด ๋ฐฐ์—ด๋กœ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํ•จ์ˆ˜.

vector<string> split(const string& input, string delimiter)
{
	vector<string> result;
	auto start = 0;
	auto end = input.find(delimiter);
	while (end != string::npos)
	{
		result.push_back(input.substr(start, end - start));
		start = end + delimiter.size();
		end = input.find(delimiter, start);
	}
	result.push_back(input.substr(start));
	return result;
}

๐Ÿš€์ „์ฒด ์ฝ”๋“œ

vector<string> split(const string& input, string delimiter)
{
	vector<string> result;
	auto start = 0;
	auto end = input.find(delimiter);
	while (end != string::npos)
	{
		result.push_back(input.substr(start, end - start));
		start = end + delimiter.size();
		end = input.find(delimiter, start);
	}
	result.push_back(input.substr(start));
	return result;
}

ํƒœ๊ทธ:

์นดํ…Œ๊ณ ๋ฆฌ:

์—…๋ฐ์ดํŠธ: