lab3/string_utils.cpp
std::vector<std::string> StringUtils::split(const std::string& s,
		const std::string& delimiters) {
	std::vector<std::string> tokens;
	std::set<char> delim(delimiters.begin(), delimiters.end());
	int last = 0;
	for ( int i = 0; i <= (int)s.size(); ++i ) {
		if ( i == (int)s.size() || delim.find(s[i]) != delim.end() ) {
			if(i-last >= 1)
				tokens.push_back(std::string(s.begin()+last, s.begin()+i));
			last = i+1;
		}
	}
	return tokens;
}
/**
 * Razdvaja string na temelju znakova u nizu delimiters.
 * Npr. split("a,b,cd.efg,", ",.") -> "a", "b", "cd", "efg"
 */
Razdvaja string na temelju znakova u nizu delimiters.
Npr.
Razdvaja string na temelju znakova u nizu delimiters . Npr .
std::vector<std::string> StringUtils::split(const std::string& s,
		const std::string& delimiters) {
	std::vector<std::string> tokens;
	std::set<char> delim(delimiters.begin(), delimiters.end());
	int last = 0;
	for ( int i = 0; i <= (int)s.size(); ++i ) {
		if ( i == (int)s.size() || delim.find(s[i]) != delim.end() ) {
			if(i-last >= 1)
				tokens.push_back(std::string(s.begin()+last, s.begin()+i));
			last = i+1;
		}
	}
	return tokens;
}
std :: vector < std :: string > StringUtils :: split ( const std :: string & s , const std :: string & delimiters ) { std :: vector < std :: string > tokens ; std :: set < char > delim ( delimiters . begin ( ) , delimiters . end ( ) ) ; int last = 0 ; for ( int i = 0 ; i <= ( int ) s . size ( ) ; ++ i ) { if ( i == ( int ) s . size ( ) || delim . find ( s [ i ] ) != delim . end ( ) ) { if ( i - last >= 1 ) tokens . push_back ( std :: string ( s . begin ( ) + last , s . begin ( ) + i ) ) ; last = i + 1 ; } } return tokens ; }
Razdvaja string na temelju znakova u nizu delimiters.
Razdvaja string na temelju znakova u nizu delimiters .